Link to home
Start Free TrialLog in
Avatar of Squadless
Squadless

asked on

Multiple LOGGERS in 1 java class

Hi,
I have a class that based on a parameter branches out to some piece of logic.  I need to have INFO level logging for any path of execution.  
I have defined a logger
private static final Logger LOGGER = LoggerFactory.getLogger(MyClass.class);

I've also defined a certain amount of appenders relevant to each of the paths of executions which log to specific unique log files.
if i use LOGGER.info("blah"), it will log all the info to ALL the files.  

My question is, Lets say i have a function with a switch statement, how can i create many loggers so that i can say something like this:
LOGGERX1.info("x1 process"); // this will log info level to a file called x1.log
LOGGERX2.info("x2 process"); // this will log info level to a file called x2.log

from the same function so that even though all the loggers are INFO level, only certain logger receives the notification to log there rather then all have the same info...

Please help.
Thanks
ASKER CERTIFIED SOLUTION
Avatar of dpearson
dpearson

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial