-
Notifications
You must be signed in to change notification settings - Fork 204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there an example of using Common Logging with .Net Core 2.0? #153
Comments
Here's another example using appsettings.json and Microsoft.Extensions.Configuration instead of setting it up programmatically. appsettings,json {
"LogConfiguration": {
"factoryAdapter": {
"type": "Common.Logging.NLog.NLogLoggerFactoryAdapter, Common.Logging.NLog4412",
"arguments": {
"configType": "FILE",
"configFile": "~/nlog.config"
}
}
}
} Setup: using Common.Logging;
using Common.Logging.Configuration;
using Microsoft.Extensions.Configuration;
IConfiguration config = new ConfigurationBuilder()
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.Build();
LogConfiguration logConfiguration = new LogConfiguration();
config.GetSection("LogConfiguration").Bind(logConfiguration);
LogManager.Configure(logConfiguration); Usage: private static readonly ILog log = LogManager.GetLogger(typeof(SomeClass)); or private static readonly ILog log = LogManager.GetLogger<SomeClass>(); |
asjafjell
pushed a commit
to digipost/signature-api-client-dotnet
that referenced
this issue
Jan 18, 2018
- Prosjektstruktur er nå klar, og de fleste tester kjører - All logging er disablet fordi Common.Logging ikke er støttet i netstandard2.0. Det kan se ut til at en hacky fiks på det er her net-commons/common-logging#153. Det kommer nok ikke til å bli støttet før i versjon 4.0, så kanskje ikke umiddelbart :(
asjafjell
pushed a commit
to digipost/signature-api-client-dotnet
that referenced
this issue
Oct 17, 2018
- Prosjektstruktur er nå klar, og de fleste tester kjører - All logging er disablet fordi Common.Logging ikke er støttet i netstandard2.0. Det kan se ut til at en hacky fiks på det er her net-commons/common-logging#153. Det kommer nok ikke til å bli støttet før i versjon 4.0, så kanskje ikke umiddelbart :(
asjafjell
pushed a commit
to digipost/signature-api-client-dotnet
that referenced
this issue
Oct 23, 2018
- Prosjektstruktur er nå klar, og de fleste tester kjører - All logging er disablet fordi Common.Logging ikke er støttet i netstandard2.0. Det kan se ut til at en hacky fiks på det er her net-commons/common-logging#153. Det kommer nok ikke til å bli støttet før i versjon 4.0, så kanskje ikke umiddelbart :(
Team was asking this question and a google search came back with this page. I like the response provided by @Troncek |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I spent a bit of time digging around, trying to find an example of a NETCore 2.0 app that used Common Logging 3.4.1 (with NLog) and couldn't find one.
In the end, I figured it out on my own through trial & error.
(I'm eagerly waiting for Common Logging 4.x!)
Is there an official example available (that I couldn't find)?
If not, here is what I had to do:
The issue I had was that in netcore20, finding configuration files is a lot different. (nlog.config file has to be available in the executing folder in this snippet)
The text was updated successfully, but these errors were encountered: