c# - Logging in .NET with Serilog -


in application, users can run multiple jobs, each of operations on files , output file. in course of these operations need log errors run in multiple log files, 1 per job.

i know can set different sinks (i.e. multiple log files) in code serilog, i'm injecting service performing operations , logging there. service injected api controller calls service methods.

what i'm not sure here how handle calling serilog logging methods within controller, since need logging in there while still using same sink i'm using in service. example, 1 job there 1 log file shared between controller , service duration of job.

if expose interface method like

public void setlogfile(string filename) {     log.logger = new loggerconfiguration()         .writeto.rollingfile(pathformat: _hostingenvironment.contentrootpath + "/" + filename + ".log",                              outputtemplate: "{timestamp:yyyy-mm-dd hh:mm:ss.fff zzz} {sourcecontext} [{level}] {message}{newline}{exception}")         .createlogger(); } 

in service call controller or wherever, configuration global , usable in controller if inject ilogger in there?

any tips appreciated!


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -