let's start coding:
@Startup
@Singleton
import org.apache.log4j.Logger;
public class MyClass{
public static final Logger logger = Logger.getLogger(MyClass.class.getSimpleName());
@PostConstruct
private void invoke() {
LOG.info("INFO");
LOG.warn("WARN");
LOG.error("ERROR");
LOG.fatal("FATAL");
LOG.debug("DEBUG");
LOG.trace("TRACE");
}
}
and if I change:
<root-logger> <level name="INFO"/>...</root-logger> to "DEBUG" instead of "INFO"
I have debug console. everything works fine.
now I want to change something.
I want generally root-logger to be "INFO". but with X.Y.Z package to be "DEBUG";
something like that, but it does not working:
<logger category="XXX.YYY.ZZZ" use-parent-handlers="false">
<level name="DEBUG"/>
</logger>
<root-logger>
<level name="INFO"/>
<handlers>
<handler name="CONSOLE"/>
<handler name="FILE"/>
</handlers>
</root-logger>
In the other words. I only want to debug XXX.YYY.ZZZ package. not another packages ("INFO" for another packages). may be I need some filters or exception.
this XML does not works because hierarchy order of log4j is that:
OFF <------ PERMITED
FATAL <------ PERMITED
ERROR <------ PERMITED
WARN <------ PERMITED
INFO <----- COSTUME LOGGING PERMITTED UP TO INFO (if root-logger is "INFO)
DEBUG
TRACE
ALL
if my root-logger is "INFO" then have permission only to create costume logging to current package with hierarchy UP TO INFO
but I need some exception or something like that. I don't need any XML configuration file or properties file. I need only to change standlone.xml