Your code is fine. But the logger names in your configuration don't match the code. Everything is going to go to only the root logger.
Sent from my iPad > On Nov 27, 2015, at 1:45 AM, Pranaya Behera <[email protected]> wrote: > > This is my pom.xml > > <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> > <version>${slf4j-version}</version> </dependency> <dependency> > <groupId>org.apache.logging.log4j</groupId> > <artifactId>log4j-core</artifactId> <version>${log4j-version}</version> > </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> > <artifactId>log4j-slf4j-impl</artifactId> > <version>${log4j-slf4j-version}</version> </dependency> <dependency> > <groupId>org.apache.logging.log4j</groupId> > <artifactId>log4j-web</artifactId> <version>${log4j-version}</version> > </dependency> > > > And in my code: > > import org.slf4j.Logger; import org.slf4j.LoggerFactory; private static final > Loggerlogger = LoggerFactory.getLogger(User.class); logger.error("Error", > exception); > > I am using slf4j with log4j2-impl. Is the code part wrong ? >> On Friday 27 November 2015 02:00 PM, Ralph Goers wrote: >> So in your code you have >> >> Logger logger = LogManager.getLogger(“Info”); >> >> logger.info(“blah blah blah”); >> >> and >> >> Logger logger = LogManager.getLogger(“Console Output”); >> logger.debug(“a debug message”); >> >> ? >> >> Those are very strange logger names. >> >> Ralph >> >> >>> On Nov 27, 2015, at 1:02 AM, Pranaya Behera <[email protected]> wrote: >>> >>> Hi, >>> I have this log4j2.json on my resources dir. I am running jetty >>> (embedded server). >>> >>> { >>> "configuration": { >>> "status": "TRACE", "name": "App", "monitorInterval": "300", >>> "appenders": { >>> "appender": [ >>> { >>> "type": "Console", "name": "STDOUT", "PatternLayout": { >>> "pattern": "%m%n" } >>> }, { >>> "type": "RollingFile", "name": "RollingFile", >>> "PatternLayout": { >>> "pattern": "%m%n" }, "filename": >>> "${sys:user.home}/console.log", "filePattern": >>> "${sys:user.home}/$${date:yyyy-MM}/console-%d{MM-dd-yyyy}-%i.log", >>> "TimeBasedTriggeringPolicy": { >>> "interval": 24, "modulate": true } >>> }, { >>> "type": "RollingFile", "name": "text-roll", >>> "PatternLayout": { >>> "pattern": "%d %p %c{1.} [%t] %m %ex%n" }, >>> "filename": "${sys:user.home}/info.log", "filePattern": >>> "${sys:user.home}/$${date:yyyy-MM}/info-%d{MM-dd-yyyy}-%i.log", >>> "TimeBasedTriggeringPolicy": { >>> "interval": 24, "modulate": true } >>> }, { >>> "type": "RollingFile", "name": "json-roll", >>> "JsonLayout": { >>> "complete": true, "compact": true, "eventEol": true >>> }, "filename": "${sys:user.home}/json.log", "filePattern": >>> "${sys:user.home}/$${date:yyyy-MM}/json-%d{MM-dd-yyyy}-%i.log", >>> "TimeBasedTriggeringPolicy": { >>> "interval": 24, "modulate": true } >>> } >>> ] >>> }, "loggers": { >>> "logger": [ >>> { >>> "name":"Console Root", "level": "TRACE", "AppenderRef": { >>> "ref": "STDOUT" } >>> }, { >>> "name":"Console Output", "level": "TRACE", >>> "AppenderRef": { >>> "ref": "RollingFile" } >>> }, { >>> "name":"Info", "level": "INFO", "AppenderRef": { >>> "ref": "text-roll" } >>> }, { >>> "name":"Json", "level": "ERROR", "AppenderRef": { >>> "ref": "json-roll" } >>> } >>> ], "root": { >>> "level" : "ALL", "AppenderRef": { >>> "ref": "STDOUT" } >>> } >>> } >>> } >>> } >>> >>> While it does create those file but never writes to those anything. In the >>> console.log, info.log is empty. But json.log has this content if I try to >>> request one endpoint on my jersey webservice. >>> >>> |[] | >>> >>> While starting my main app for the jetty server this is the console log >>> that is coming: >>> >>> https://gist.github.com/shadow-fox/15ec570068adb9a7ac31 >>> Can someone help me what's wrong in the configuration or why it is not >>> writing anything to those file? >>> >>> -- >>> Thanks & Regards >>> Pranaya Behera >>> >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [email protected] >> For additional commands, e-mail: [email protected] >> > -- > Thanks & Regards > Pranaya Behera --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
