You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was wondering if it is possible to make use of a static ILogger. My code contains a special wrapper class which adds some metadata and is also responsible to format log messages in a consistent way. What I tried was exposing the ILogger from the wrapper class (SpecialLogger in the example), and setting it as the globally shared logger. I'm using this logger through out multiple assemblies, so using the ILogger injected into the webjob function isn't an option to me.
Example:
class Program
{
public static readonly SpecialLogger SpecialLogger = SpecialLogger.Create("Test");
static void Main()
{
// Here I try to make the underlying ILogger globally shared
Log.Logger = SpecialLogger.Logger;
var config = new JobHostConfiguration();
config.UseSerilog();
var host = new JobHost(config);
// The following code ensures that the WebJob will be running continuously
host.RunAndBlock();
}
}
The text was updated successfully, but these errors were encountered:
Hi there,
I was wondering if it is possible to make use of a static ILogger. My code contains a special wrapper class which adds some metadata and is also responsible to format log messages in a consistent way. What I tried was exposing the ILogger from the wrapper class (
SpecialLogger
in the example), and setting it as the globally shared logger. I'm using this logger through out multiple assemblies, so using the ILogger injected into the webjob function isn't an option to me.Example:
The text was updated successfully, but these errors were encountered: