Created
November 7, 2022 12:22
-
-
Save warrenbuckley/2ca102a9d17516c3b257a967089026d5 to your computer and use it in GitHub Desktop.
Example V9+ Umbraco CMS Serilog Configuration to write to additional File location
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema" : "./appsettings-schema.json", | |
"Serilog": { | |
"MinimumLevel": { | |
"Default": "Information", | |
"Override": { | |
"Examine.Lucene.Providers.LuceneIndex": "Debug", | |
"Examine.BaseIndexProvider": "Debug", | |
"Examine.Lucene.LoggingReplicationClient": "Debug", | |
"Examine.Lucene.ExamineReplicator": "Debug" | |
} | |
}, | |
"WriteTo": [ | |
{ | |
"Name": "File", | |
"Args": { | |
"path": "warren-logs/log-.json", | |
"formatter": "Serilog.Formatting.Compact.CompactJsonFormatter, Serilog.Formatting.Compact", | |
"rollingInterval": "Day", | |
"buffered": true, | |
"retainedFileCountLimit": "2" | |
} | |
}, | |
{ | |
"Name": "Async", | |
"Args": { | |
"configure": [ | |
{ | |
"Name": "Console" | |
} | |
] | |
} | |
} | |
] | |
}, | |
"Umbraco": { | |
"CMS": { | |
"Examine": { | |
"LuceneDirectoryFactory": "TempFileSystemDirectoryFactory" | |
}, | |
"Global": { | |
"Smtp": { | |
//"From": "[email protected]", | |
//"Host": "localhost", | |
// "Port": "25" | |
} | |
}, | |
"Hosting": { | |
"Debug": true | |
}, | |
"RuntimeMinification": { | |
"useInMemoryCache": true, | |
"cacheBuster": "Timestamp" | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Taking this one step further and making it possible to view the logs in the backoffice log viewer:
Step 1:
Configure a custom File-zink to write to and configure Umbraco to only write Fatal-errors to the "old" log path.
NOTE: Added buffered:false and shared:false.
Step 2
Implement your own
Umbraco.Cms.Core.Logging.ILoggingConfiguration
and return the path to where you're storing the files.Switch the it in the DI during startup after Umbraco has registered it's dependencies.