Questions tagged [loggerfactory]
40 questions
7
votes
1 answer
How do I write to a custom event source using .net core's ILoggerFactory? Is there a way to specify the source?
I am trying to write to a custom event source in .netcore/c# but have not found a way to specify the target source of .net core's logger object. In this case, I want to write to "My Event Log" as opposed to the Application log. The code below writes…

John Nettles
- 161
- 1
- 8
3
votes
0 answers
How to use ILoggerFactory and log to the console
I created a simple console application in .Net Core 3.1.
I want to create a logger and print it to the console.
I have the following code
class Program
{
public static void Main(string[] args)
{
var loggerFactory =…

Yaniv daye
- 73
- 7
3
votes
1 answer
How to configure ILogger in Console App with .Net Framework (not .Net Core)
Is it possible to use an ILogger log in a .Net Framework console app? I searched a lot but I wasn't able to find a sample. This is what I came up with so far
var loggerFactory = new LoggerFactory();
//loggerFactory.AddProvider();
…

Nicolae Daian
- 1,065
- 3
- 18
- 39
3
votes
1 answer
Logback Maven java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
I get the following after running a Jar (Maven project):
java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
The error is caused in the declaration of the variable:
private static final Logger logger =…

Alessandroempire
- 1,640
- 4
- 31
- 54
2
votes
0 answers
Microsoft.Extensions.Logging and Serilog logger configurations
In my WPF .netCore 5 app, I'm using three libraries where each library accepts Microsoft.Extensions.Logging.ILogger at initialization. I'm using Serilog and ILoggerFactory. I create three LoggerConfigurations with different WriteTo.File…

zmuro
- 21
- 3
2
votes
0 answers
Create custom log level in Spring boot logback-spring.xml
Team,
I want to be create custom log level in logback-spring.xml in spring boot. like we have info, debug,warn same like want to create my own custom level.
any suggestion ?

Gaurav Khandelwal
- 360
- 2
- 12
2
votes
1 answer
netcore: create a console logger using LoggerBuilder from a test controller
I have a test project, in which I setup an http client like this:
public class TestContext : IDisposable
{
private TestServer _server;
public HttpClient Client { get; private set; }
public TestContext() {
SetUpClient();
}
…

opensas
- 60,462
- 79
- 252
- 386
2
votes
2 answers
Can't use @Slf4j annotation in my project because can't be resolved to a type but in another project works well
I moved a functionality of my Maven project because instead of a file.war, I wanted a .jar file to be able to run it from the command line. The problem is when I have been copying the dependencies of this project to the new one, my pom is the next…

aarauz
- 21
- 1
- 3
2
votes
2 answers
LoggerFactory cannot getLogger
I'm currently implementing a Logger and I'm wondering why the code won't run.
Most of the codes snipets are like these:
Logger log = LoggerFactory.getLogger(this.getClass());
My imported classes:
import org.osgi.framework.BundleContext;
import…

mengmeng
- 1,266
- 2
- 22
- 46
2
votes
1 answer
Asp.net core get logger in ConfigureAppConfiguration
I would like to use logger in "TODO" line, because I need to log when I add a "AddJsonConfigurationSourceDecryption" method, Is there any way to get a logger?
Logging in ASP.NET Core
public class Program
{
public static void Main(string[]…

Joans
- 31
- 3
1
vote
2 answers
Use Generic ILogger Instance with Autofac
I have the following Code.
public class TypeA : InterfaceA
{
private ILogger _logger;
public TypeA(ILogger logger)
{
_logger = logger;
}
}
public class Main
{
...
var loggerFactory = new LoggerFactory();
…

Cellcon
- 1,245
- 2
- 11
- 27
1
vote
1 answer
.NET Non-host LoggerFactory configuration
I am trying to add logging to an existing .NET Framework application. I have added my own logger (called MyLogger) and put the config settings into appsettings.json like this:
{
"LogFilePath": "C:\\Temp\\Logs\\%yyyy-%MM-%dd.txt",
"Logging": {
…

Sandy
- 1,284
- 2
- 14
- 32
1
vote
1 answer
How to add ILoggerFactory to Startup dotnet core 3.1
I'm using dotnet core 3.1 and I want to add ILoggerFactory to startup constructor.
But I get an error:
'Unable to resolve service for type
'Microsoft.Extensions.Logging.ILoggerFactory' while attempting to
activate 'Startup'.'
My configuration in…

Saeid Mirzaei
- 950
- 2
- 18
- 48
1
vote
0 answers
logs not getting generated by LoggerFactory
I am using slf4j for generating logs and using Loggerfactory class.
Here is my code
@Override
public void afterScenario(ScenarioResult result, ScenarioContext context) {
LoggerFactory.getLogger(getClass()).info("The Result of…

Hardik Rana
- 476
- 1
- 6
- 16
1
vote
1 answer
How to create a LogFile and path with LoggerFactory
EDIT This is my batchfile code to run a (.bat) File , and i try to convert the output of the bat into a Logfile ,but i dont want to set the name of the logfile automatically , for every bat i want to run , create a new logfile with a the name of the…

KmanTheMan
- 27
- 5