neo007
neo007

Reputation: 27

Java Loggining to 2 different files

By the below post i can able to configure log4j to log in N different file.

Creating multiple log files of different content with log4j

log4j: Log output of a specific class to a specific appender

But i question is FOO.java should able to log in 2 different files. Normal debug/infos in general logger and some statistics in different logger.

I use slf4j and log4j.. I can able to change the logging framework if needed.

Upvotes: 0

Views: 75

Answers (1)

Andreas
Andreas

Reputation: 159086

Normally, loggers are named after the class, but you don't have to do that. You can name the logger something totally different, or use the class name with some prefix or suffix, e.g. for class org.example.Foo:

org.example.Foo          <-- Standard logger name
org.example.Foo.stats
stats.org.example.Foo
Foo.stats
stats.Foo
stats.Bar

Using a prefix will allow you to redirect statistics from all sources (classes) to a separate file, in one config entry.

You decide what is appropriate for you.

Upvotes: 1

Related Questions