4.9 KiB
Logging Guide for PowderCoating Application
Log File Locations
When you deploy the application to your testing server, logs will be written to:
On Windows Server
C:\inetpub\wwwroot\YourAppFolder\logs\
or wherever your application is deployed to.
Log Files Created
-
powdercoating-YYYYMMDD.txt - All application logs (Info, Warning, Error)
- Contains general application activity
- Includes request logs with user information
- New file created daily
- Keeps last 30 days
-
errors-YYYYMMDD.txt - Error logs only
- Contains ONLY errors and critical issues
- Check this file first when troubleshooting
- New file created daily
- Keeps last 90 days
What Gets Logged
Automatic Error Logging
-
Unhandled Exceptions: All unhandled errors are automatically logged with:
- Exception details and stack trace
- URL path where error occurred
- Username (or "Anonymous")
- Request trace ID
- Timestamp
-
HTTP Requests: All requests are logged with:
- HTTP method and path
- Response status code
- Duration
- User information
- IP address
- User agent
Log Entry Format
2026-02-11 10:30:45.123 -05:00 [ERR] [PowderCoating.Web.Controllers.JobsController] Error creating job
System.InvalidOperationException: Job validation failed
at PowderCoating.Web.Controllers.JobsController.Create(...)
Finding Logs on Your Testing Server
Step 1: Locate the Application Directory
- Connect to your testing server via RDP
- Navigate to where the application is deployed
- Look for a
logsfolder in the application root
Step 2: Check for Permissions
The application needs write permissions to the logs folder. If no logs are created:
- Right-click the
logsfolder → Properties → Security - Ensure the IIS application pool identity has "Modify" permissions
- Typically this is
IIS AppPool\YourAppPoolName
Step 3: View Current Errors
Open the most recent errors-YYYYMMDD.txt file to see all errors from today.
Troubleshooting: Logs Not Appearing
If logs folder doesn't exist:
- The application may not have started successfully
- Check Windows Event Viewer → Application logs for startup errors
- Check IIS logs in
C:\inetpub\logs\LogFiles\
If logs folder exists but empty:
- Check folder permissions (application pool needs Write access)
- Check if application is actually running
- Restart the application pool in IIS Manager
If only seeing old logs:
- Application may have crashed - check Windows Event Viewer
- Application pool may have stopped - check IIS Manager
- Restart the application pool to generate fresh startup logs
Log Levels by Environment
Development
- Logs everything at Information level and above
- Full console output with colors
- Detailed EF Core query logs
Production/Testing (Your Server)
- Logs Information level and above
- Warnings for Microsoft/System components
- Separate error log for quick troubleshooting
- Request logging enabled for audit trail
Reading the Logs
Finding Specific Errors
Use PowerShell to search logs:
# Find all errors today
Get-Content "logs\errors-$(Get-Date -Format yyyyMMdd).txt"
# Search for specific error
Select-String -Path "logs\*.txt" -Pattern "InvalidOperationException"
# Get last 50 error lines
Get-Content "logs\errors-*.txt" | Select-Object -Last 50
Common Log Patterns
Database Connection Error:
[ERR] An error occurred using the connection to database 'PowderCoatingDb'
Authentication Error:
[ERR] [Microsoft.AspNetCore.Authentication] Authentication failed
Unhandled Exception:
[ERR] [PowderCoating.Web.Controllers.*] Unhandled exception occurred
Additional Monitoring
Windows Event Viewer
For startup/crash errors that may not appear in application logs:
- Open Event Viewer
- Windows Logs → Application
- Filter by Source: "ASP.NET Core"
IIS Logs
For HTTP-level issues:
- Location:
C:\inetpub\logs\LogFiles\W3SVC*\ - Shows HTTP status codes, response times
- Useful for 500 errors, timeouts
Log Retention
- General Logs: Last 30 days automatically retained
- Error Logs: Last 90 days automatically retained
- Older logs are automatically deleted to save disk space
- Archive important logs if you need long-term retention
Performance Impact
The current logging configuration:
- Minimal impact on application performance
- Logs are written asynchronously
- File writes are flushed every 1 second
shared: trueallows multiple processes to write to same log file
Next Steps: Production Logging Improvements
For production deployment, consider:
- Azure Application Insights - Cloud-based monitoring and alerting
- Seq - Structured log server with web UI
- ELK Stack - Elasticsearch, Logstash, Kibana
- Centralized logging - Aggregate logs from multiple servers
Contact your DevOps team to set up one of these for production.