slf4j logging not printing in server.log file instead it is printing on console - wildfly
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I have satndalone.xml
with logging config, and pom.xml
with slf4j
dependency configured. Using lombok.extern.slf4j.Slf4j
api annotations(@Slf4j
) for logging in java classes.
The issue is the logs using this Slf4j are printing on console but not printing in the server.log
File in wildfly server
.
I have given logging config of standalone.xml
(and also logging.properties
whose configuration values will be from standalone.xml
) and logging config of pom.xml
Logger in java class:
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class AuthenticateABC {
.
.
.
.
methodABC() {
log.error("authenticateUser NoResultException = " + nre.getMessage());
}
Logging config from standalone.xml in wildfly server:
<profile>
<subsystem xmlns="urn:jboss:domain:logging:3.0">
<console-handler name="CONSOLE" autoflush="true">
<level name="ERROR"/>
<formatter>
<named-formatter name="COLOR-PATTERN"/>
</formatter>
</console-handler>
<periodic-rotating-file-handler name="FILE" autoflush="true">
<level name="TRACE"/>
<formatter>
<named-formatter name="PATTERN"/>
</formatter>
<file relative-to="jboss.server.log.dir" path="server.log"/>
<suffix value=".yyyy-MM-dd"/>
<append value="true"/>
</periodic-rotating-file-handler>
<logger category="com.arjuna">
<level name="ERROR"/>
</logger>
<logger category="org.hibernate">
<level name="ERROR"/>
</logger>
<logger category="org.jboss">
<level name="ERROR"/>
</logger>
<logger category="org.jboss.as.config">
<level name="ERROR"/>
</logger>
<logger category="sun.rmi">
<level name="ERROR"/>
</logger>
<root-logger>
<level name="TRACE"/>
<handlers>
<handler name="FILE"/>
</handlers>
</root-logger>
<formatter name="PATTERN">
<pattern-formatter pattern="%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n"/>
</formatter>
<formatter name="COLOR-PATTERN">
<pattern-formatter pattern="%K{level}%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n"/>
</formatter>
</subsystem>
logging.properties:
loggers=sun.rmi,org.jboss.as.config,org.hibernate,org.jboss,com.arjuna
logger.level=TRACE
logger.handlers=FILE
logger.sun.rmi.level=ERROR
logger.sun.rmi.useParentHandlers=true
logger.org.jboss.as.config.level=ERROR
logger.org.jboss.as.config.useParentHandlers=true
logger.org.hibernate.level=ERROR
logger.org.hibernate.useParentHandlers=true
logger.org.jboss.level=ERROR
logger.org.jboss.useParentHandlers=true
logger.com.arjuna.level=ERROR
logger.com.arjuna.useParentHandlers=true
# Additional handlers to configure
handlers=CONSOLE
handler.CONSOLE=org.jboss.logmanager.handlers.ConsoleHandler
handler.CONSOLE.level=ERROR
handler.CONSOLE.formatter=COLOR-PATTERN
handler.CONSOLE.properties=autoFlush,target,enabled
handler.CONSOLE.autoFlush=true
handler.CONSOLE.target=SYSTEM_OUT
handler.CONSOLE.enabled=true
handler.FILE=org.jboss.logmanager.handlers.PeriodicRotatingFileHandler
handler.FILE.level=TRACE
handler.FILE.formatter=PATTERN
handler.FILE.properties=append,autoFlush,enabled,suffix,fileName
handler.FILE.constructorProperties=fileName,append
handler.FILE.append=true
handler.FILE.autoFlush=true
handler.FILE.enabled=true
handler.FILE.suffix=.yyyy-MM-dd
handler.FILE.fileName=C:\wildfly-10.1.0.Final\standalone\log\server.log
formatter.PATTERN=org.jboss.logmanager.formatters.PatternFormatter
formatter.PATTERN.properties=pattern
formatter.PATTERN.pattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n
formatter.COLOR-PATTERN=org.jboss.logmanager.formatters.PatternFormatter
formatter.COLOR-PATTERN.properties=pattern
formatter.COLOR-PATTERN.pattern=%K{level}%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n
pom.xml
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>1.0.0.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.3.0.Final</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
<type>zip</type>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.12</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.12</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging-processor</artifactId>
<version>2.1.0.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
<version>3.3.0.Final</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.18</version>
</dependency>
when I configure standalone.xml
<console-handler>
log <level>
to ERROR
and <periodic-rotating-file-handler>
log <level>
to TRACE
, I expect the debug log of slf4j log.debug("authenticateUser = " + currentUser);
in my java code to be printed in server.log
file, but this is printing on console.
2019-01-04 DEBUG [default task-8] (AuthenticateABC.java:98) - authenticateUser = APPUSER
I have tried several combinations of log levels and handlers, but still no luck, don't know what is wrong.
java log4j wildfly pom.xml slf4j-api
|
show 1 more comment
I have satndalone.xml
with logging config, and pom.xml
with slf4j
dependency configured. Using lombok.extern.slf4j.Slf4j
api annotations(@Slf4j
) for logging in java classes.
The issue is the logs using this Slf4j are printing on console but not printing in the server.log
File in wildfly server
.
I have given logging config of standalone.xml
(and also logging.properties
whose configuration values will be from standalone.xml
) and logging config of pom.xml
Logger in java class:
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class AuthenticateABC {
.
.
.
.
methodABC() {
log.error("authenticateUser NoResultException = " + nre.getMessage());
}
Logging config from standalone.xml in wildfly server:
<profile>
<subsystem xmlns="urn:jboss:domain:logging:3.0">
<console-handler name="CONSOLE" autoflush="true">
<level name="ERROR"/>
<formatter>
<named-formatter name="COLOR-PATTERN"/>
</formatter>
</console-handler>
<periodic-rotating-file-handler name="FILE" autoflush="true">
<level name="TRACE"/>
<formatter>
<named-formatter name="PATTERN"/>
</formatter>
<file relative-to="jboss.server.log.dir" path="server.log"/>
<suffix value=".yyyy-MM-dd"/>
<append value="true"/>
</periodic-rotating-file-handler>
<logger category="com.arjuna">
<level name="ERROR"/>
</logger>
<logger category="org.hibernate">
<level name="ERROR"/>
</logger>
<logger category="org.jboss">
<level name="ERROR"/>
</logger>
<logger category="org.jboss.as.config">
<level name="ERROR"/>
</logger>
<logger category="sun.rmi">
<level name="ERROR"/>
</logger>
<root-logger>
<level name="TRACE"/>
<handlers>
<handler name="FILE"/>
</handlers>
</root-logger>
<formatter name="PATTERN">
<pattern-formatter pattern="%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n"/>
</formatter>
<formatter name="COLOR-PATTERN">
<pattern-formatter pattern="%K{level}%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n"/>
</formatter>
</subsystem>
logging.properties:
loggers=sun.rmi,org.jboss.as.config,org.hibernate,org.jboss,com.arjuna
logger.level=TRACE
logger.handlers=FILE
logger.sun.rmi.level=ERROR
logger.sun.rmi.useParentHandlers=true
logger.org.jboss.as.config.level=ERROR
logger.org.jboss.as.config.useParentHandlers=true
logger.org.hibernate.level=ERROR
logger.org.hibernate.useParentHandlers=true
logger.org.jboss.level=ERROR
logger.org.jboss.useParentHandlers=true
logger.com.arjuna.level=ERROR
logger.com.arjuna.useParentHandlers=true
# Additional handlers to configure
handlers=CONSOLE
handler.CONSOLE=org.jboss.logmanager.handlers.ConsoleHandler
handler.CONSOLE.level=ERROR
handler.CONSOLE.formatter=COLOR-PATTERN
handler.CONSOLE.properties=autoFlush,target,enabled
handler.CONSOLE.autoFlush=true
handler.CONSOLE.target=SYSTEM_OUT
handler.CONSOLE.enabled=true
handler.FILE=org.jboss.logmanager.handlers.PeriodicRotatingFileHandler
handler.FILE.level=TRACE
handler.FILE.formatter=PATTERN
handler.FILE.properties=append,autoFlush,enabled,suffix,fileName
handler.FILE.constructorProperties=fileName,append
handler.FILE.append=true
handler.FILE.autoFlush=true
handler.FILE.enabled=true
handler.FILE.suffix=.yyyy-MM-dd
handler.FILE.fileName=C:\wildfly-10.1.0.Final\standalone\log\server.log
formatter.PATTERN=org.jboss.logmanager.formatters.PatternFormatter
formatter.PATTERN.properties=pattern
formatter.PATTERN.pattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n
formatter.COLOR-PATTERN=org.jboss.logmanager.formatters.PatternFormatter
formatter.COLOR-PATTERN.properties=pattern
formatter.COLOR-PATTERN.pattern=%K{level}%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n
pom.xml
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>1.0.0.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.3.0.Final</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
<type>zip</type>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.12</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.12</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging-processor</artifactId>
<version>2.1.0.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
<version>3.3.0.Final</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.18</version>
</dependency>
when I configure standalone.xml
<console-handler>
log <level>
to ERROR
and <periodic-rotating-file-handler>
log <level>
to TRACE
, I expect the debug log of slf4j log.debug("authenticateUser = " + currentUser);
in my java code to be printed in server.log
file, but this is printing on console.
2019-01-04 DEBUG [default task-8] (AuthenticateABC.java:98) - authenticateUser = APPUSER
I have tried several combinations of log levels and handlers, but still no luck, don't know what is wrong.
java log4j wildfly pom.xml slf4j-api
Are you editing these files when the server is running? The console handler doesn't look assigned to anything so it should get nothing printed to it. Another possibility is you have a logging configuration file in your deployment.
– James R. Perkins
Jan 6 at 21:29
No, I am not editing these files, when server running. I don't know where another logging config can be there in deployment, could you please tell me in which directory it can be in wildfly server. Thing is when ever I change the logging config likelog level
fromdebug
toerror
or<root-logger> <handlers>
fromconsole
toFILE
in the standalone.xml file, the values are getting into effect and the log content is changing accordingly, so I am thinking that I am working on the right configuration file.
– ddc
Jan 7 at 9:52
@JamesR.Perkins Thanks, I found where the another logging configuration file is in my application. There is a 'log4j.properties` file insrcmainresources
folder. This file contains wrong file path configurationslog4j.appender.file.File=XYZ.log
, due to which the log is being written in XYZ.log file located in wildfly bin directory. After changing this path to server.loglog4j.appender.file.File=${jboss.server.log.dir}/server.log
the log is writing intoserver.log
file.
– ddc
Jan 7 at 15:53
Ah yes that would do it. There is an attribute you can change to disable that. I'd also suggest using the web console or CLI to make changes as there would be no reason to shutdown the server first.
– James R. Perkins
Jan 7 at 17:37
+1 I have singlewildfly server
in which I have to deploy multiple web applications, in this case, I believe I have to use different logging configuration file to each web application so that each application will have separate log file specific to that application. For this reason I am maintaining one more logging configuration file inside the application, along withstandalone.xml
config.
– ddc
Jan 10 at 10:44
|
show 1 more comment
I have satndalone.xml
with logging config, and pom.xml
with slf4j
dependency configured. Using lombok.extern.slf4j.Slf4j
api annotations(@Slf4j
) for logging in java classes.
The issue is the logs using this Slf4j are printing on console but not printing in the server.log
File in wildfly server
.
I have given logging config of standalone.xml
(and also logging.properties
whose configuration values will be from standalone.xml
) and logging config of pom.xml
Logger in java class:
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class AuthenticateABC {
.
.
.
.
methodABC() {
log.error("authenticateUser NoResultException = " + nre.getMessage());
}
Logging config from standalone.xml in wildfly server:
<profile>
<subsystem xmlns="urn:jboss:domain:logging:3.0">
<console-handler name="CONSOLE" autoflush="true">
<level name="ERROR"/>
<formatter>
<named-formatter name="COLOR-PATTERN"/>
</formatter>
</console-handler>
<periodic-rotating-file-handler name="FILE" autoflush="true">
<level name="TRACE"/>
<formatter>
<named-formatter name="PATTERN"/>
</formatter>
<file relative-to="jboss.server.log.dir" path="server.log"/>
<suffix value=".yyyy-MM-dd"/>
<append value="true"/>
</periodic-rotating-file-handler>
<logger category="com.arjuna">
<level name="ERROR"/>
</logger>
<logger category="org.hibernate">
<level name="ERROR"/>
</logger>
<logger category="org.jboss">
<level name="ERROR"/>
</logger>
<logger category="org.jboss.as.config">
<level name="ERROR"/>
</logger>
<logger category="sun.rmi">
<level name="ERROR"/>
</logger>
<root-logger>
<level name="TRACE"/>
<handlers>
<handler name="FILE"/>
</handlers>
</root-logger>
<formatter name="PATTERN">
<pattern-formatter pattern="%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n"/>
</formatter>
<formatter name="COLOR-PATTERN">
<pattern-formatter pattern="%K{level}%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n"/>
</formatter>
</subsystem>
logging.properties:
loggers=sun.rmi,org.jboss.as.config,org.hibernate,org.jboss,com.arjuna
logger.level=TRACE
logger.handlers=FILE
logger.sun.rmi.level=ERROR
logger.sun.rmi.useParentHandlers=true
logger.org.jboss.as.config.level=ERROR
logger.org.jboss.as.config.useParentHandlers=true
logger.org.hibernate.level=ERROR
logger.org.hibernate.useParentHandlers=true
logger.org.jboss.level=ERROR
logger.org.jboss.useParentHandlers=true
logger.com.arjuna.level=ERROR
logger.com.arjuna.useParentHandlers=true
# Additional handlers to configure
handlers=CONSOLE
handler.CONSOLE=org.jboss.logmanager.handlers.ConsoleHandler
handler.CONSOLE.level=ERROR
handler.CONSOLE.formatter=COLOR-PATTERN
handler.CONSOLE.properties=autoFlush,target,enabled
handler.CONSOLE.autoFlush=true
handler.CONSOLE.target=SYSTEM_OUT
handler.CONSOLE.enabled=true
handler.FILE=org.jboss.logmanager.handlers.PeriodicRotatingFileHandler
handler.FILE.level=TRACE
handler.FILE.formatter=PATTERN
handler.FILE.properties=append,autoFlush,enabled,suffix,fileName
handler.FILE.constructorProperties=fileName,append
handler.FILE.append=true
handler.FILE.autoFlush=true
handler.FILE.enabled=true
handler.FILE.suffix=.yyyy-MM-dd
handler.FILE.fileName=C:\wildfly-10.1.0.Final\standalone\log\server.log
formatter.PATTERN=org.jboss.logmanager.formatters.PatternFormatter
formatter.PATTERN.properties=pattern
formatter.PATTERN.pattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n
formatter.COLOR-PATTERN=org.jboss.logmanager.formatters.PatternFormatter
formatter.COLOR-PATTERN.properties=pattern
formatter.COLOR-PATTERN.pattern=%K{level}%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n
pom.xml
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>1.0.0.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.3.0.Final</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
<type>zip</type>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.12</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.12</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging-processor</artifactId>
<version>2.1.0.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
<version>3.3.0.Final</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.18</version>
</dependency>
when I configure standalone.xml
<console-handler>
log <level>
to ERROR
and <periodic-rotating-file-handler>
log <level>
to TRACE
, I expect the debug log of slf4j log.debug("authenticateUser = " + currentUser);
in my java code to be printed in server.log
file, but this is printing on console.
2019-01-04 DEBUG [default task-8] (AuthenticateABC.java:98) - authenticateUser = APPUSER
I have tried several combinations of log levels and handlers, but still no luck, don't know what is wrong.
java log4j wildfly pom.xml slf4j-api
I have satndalone.xml
with logging config, and pom.xml
with slf4j
dependency configured. Using lombok.extern.slf4j.Slf4j
api annotations(@Slf4j
) for logging in java classes.
The issue is the logs using this Slf4j are printing on console but not printing in the server.log
File in wildfly server
.
I have given logging config of standalone.xml
(and also logging.properties
whose configuration values will be from standalone.xml
) and logging config of pom.xml
Logger in java class:
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class AuthenticateABC {
.
.
.
.
methodABC() {
log.error("authenticateUser NoResultException = " + nre.getMessage());
}
Logging config from standalone.xml in wildfly server:
<profile>
<subsystem xmlns="urn:jboss:domain:logging:3.0">
<console-handler name="CONSOLE" autoflush="true">
<level name="ERROR"/>
<formatter>
<named-formatter name="COLOR-PATTERN"/>
</formatter>
</console-handler>
<periodic-rotating-file-handler name="FILE" autoflush="true">
<level name="TRACE"/>
<formatter>
<named-formatter name="PATTERN"/>
</formatter>
<file relative-to="jboss.server.log.dir" path="server.log"/>
<suffix value=".yyyy-MM-dd"/>
<append value="true"/>
</periodic-rotating-file-handler>
<logger category="com.arjuna">
<level name="ERROR"/>
</logger>
<logger category="org.hibernate">
<level name="ERROR"/>
</logger>
<logger category="org.jboss">
<level name="ERROR"/>
</logger>
<logger category="org.jboss.as.config">
<level name="ERROR"/>
</logger>
<logger category="sun.rmi">
<level name="ERROR"/>
</logger>
<root-logger>
<level name="TRACE"/>
<handlers>
<handler name="FILE"/>
</handlers>
</root-logger>
<formatter name="PATTERN">
<pattern-formatter pattern="%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n"/>
</formatter>
<formatter name="COLOR-PATTERN">
<pattern-formatter pattern="%K{level}%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n"/>
</formatter>
</subsystem>
logging.properties:
loggers=sun.rmi,org.jboss.as.config,org.hibernate,org.jboss,com.arjuna
logger.level=TRACE
logger.handlers=FILE
logger.sun.rmi.level=ERROR
logger.sun.rmi.useParentHandlers=true
logger.org.jboss.as.config.level=ERROR
logger.org.jboss.as.config.useParentHandlers=true
logger.org.hibernate.level=ERROR
logger.org.hibernate.useParentHandlers=true
logger.org.jboss.level=ERROR
logger.org.jboss.useParentHandlers=true
logger.com.arjuna.level=ERROR
logger.com.arjuna.useParentHandlers=true
# Additional handlers to configure
handlers=CONSOLE
handler.CONSOLE=org.jboss.logmanager.handlers.ConsoleHandler
handler.CONSOLE.level=ERROR
handler.CONSOLE.formatter=COLOR-PATTERN
handler.CONSOLE.properties=autoFlush,target,enabled
handler.CONSOLE.autoFlush=true
handler.CONSOLE.target=SYSTEM_OUT
handler.CONSOLE.enabled=true
handler.FILE=org.jboss.logmanager.handlers.PeriodicRotatingFileHandler
handler.FILE.level=TRACE
handler.FILE.formatter=PATTERN
handler.FILE.properties=append,autoFlush,enabled,suffix,fileName
handler.FILE.constructorProperties=fileName,append
handler.FILE.append=true
handler.FILE.autoFlush=true
handler.FILE.enabled=true
handler.FILE.suffix=.yyyy-MM-dd
handler.FILE.fileName=C:\wildfly-10.1.0.Final\standalone\log\server.log
formatter.PATTERN=org.jboss.logmanager.formatters.PatternFormatter
formatter.PATTERN.properties=pattern
formatter.PATTERN.pattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n
formatter.COLOR-PATTERN=org.jboss.logmanager.formatters.PatternFormatter
formatter.COLOR-PATTERN.properties=pattern
formatter.COLOR-PATTERN.pattern=%K{level}%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n
pom.xml
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>1.0.0.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.3.0.Final</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
<type>zip</type>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.12</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.12</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging-processor</artifactId>
<version>2.1.0.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
<version>3.3.0.Final</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.18</version>
</dependency>
when I configure standalone.xml
<console-handler>
log <level>
to ERROR
and <periodic-rotating-file-handler>
log <level>
to TRACE
, I expect the debug log of slf4j log.debug("authenticateUser = " + currentUser);
in my java code to be printed in server.log
file, but this is printing on console.
2019-01-04 DEBUG [default task-8] (AuthenticateABC.java:98) - authenticateUser = APPUSER
I have tried several combinations of log levels and handlers, but still no luck, don't know what is wrong.
java log4j wildfly pom.xml slf4j-api
java log4j wildfly pom.xml slf4j-api
asked Jan 4 at 17:02
ddcddc
164
164
Are you editing these files when the server is running? The console handler doesn't look assigned to anything so it should get nothing printed to it. Another possibility is you have a logging configuration file in your deployment.
– James R. Perkins
Jan 6 at 21:29
No, I am not editing these files, when server running. I don't know where another logging config can be there in deployment, could you please tell me in which directory it can be in wildfly server. Thing is when ever I change the logging config likelog level
fromdebug
toerror
or<root-logger> <handlers>
fromconsole
toFILE
in the standalone.xml file, the values are getting into effect and the log content is changing accordingly, so I am thinking that I am working on the right configuration file.
– ddc
Jan 7 at 9:52
@JamesR.Perkins Thanks, I found where the another logging configuration file is in my application. There is a 'log4j.properties` file insrcmainresources
folder. This file contains wrong file path configurationslog4j.appender.file.File=XYZ.log
, due to which the log is being written in XYZ.log file located in wildfly bin directory. After changing this path to server.loglog4j.appender.file.File=${jboss.server.log.dir}/server.log
the log is writing intoserver.log
file.
– ddc
Jan 7 at 15:53
Ah yes that would do it. There is an attribute you can change to disable that. I'd also suggest using the web console or CLI to make changes as there would be no reason to shutdown the server first.
– James R. Perkins
Jan 7 at 17:37
+1 I have singlewildfly server
in which I have to deploy multiple web applications, in this case, I believe I have to use different logging configuration file to each web application so that each application will have separate log file specific to that application. For this reason I am maintaining one more logging configuration file inside the application, along withstandalone.xml
config.
– ddc
Jan 10 at 10:44
|
show 1 more comment
Are you editing these files when the server is running? The console handler doesn't look assigned to anything so it should get nothing printed to it. Another possibility is you have a logging configuration file in your deployment.
– James R. Perkins
Jan 6 at 21:29
No, I am not editing these files, when server running. I don't know where another logging config can be there in deployment, could you please tell me in which directory it can be in wildfly server. Thing is when ever I change the logging config likelog level
fromdebug
toerror
or<root-logger> <handlers>
fromconsole
toFILE
in the standalone.xml file, the values are getting into effect and the log content is changing accordingly, so I am thinking that I am working on the right configuration file.
– ddc
Jan 7 at 9:52
@JamesR.Perkins Thanks, I found where the another logging configuration file is in my application. There is a 'log4j.properties` file insrcmainresources
folder. This file contains wrong file path configurationslog4j.appender.file.File=XYZ.log
, due to which the log is being written in XYZ.log file located in wildfly bin directory. After changing this path to server.loglog4j.appender.file.File=${jboss.server.log.dir}/server.log
the log is writing intoserver.log
file.
– ddc
Jan 7 at 15:53
Ah yes that would do it. There is an attribute you can change to disable that. I'd also suggest using the web console or CLI to make changes as there would be no reason to shutdown the server first.
– James R. Perkins
Jan 7 at 17:37
+1 I have singlewildfly server
in which I have to deploy multiple web applications, in this case, I believe I have to use different logging configuration file to each web application so that each application will have separate log file specific to that application. For this reason I am maintaining one more logging configuration file inside the application, along withstandalone.xml
config.
– ddc
Jan 10 at 10:44
Are you editing these files when the server is running? The console handler doesn't look assigned to anything so it should get nothing printed to it. Another possibility is you have a logging configuration file in your deployment.
– James R. Perkins
Jan 6 at 21:29
Are you editing these files when the server is running? The console handler doesn't look assigned to anything so it should get nothing printed to it. Another possibility is you have a logging configuration file in your deployment.
– James R. Perkins
Jan 6 at 21:29
No, I am not editing these files, when server running. I don't know where another logging config can be there in deployment, could you please tell me in which directory it can be in wildfly server. Thing is when ever I change the logging config like
log level
from debug
to error
or <root-logger> <handlers>
from console
to FILE
in the standalone.xml file, the values are getting into effect and the log content is changing accordingly, so I am thinking that I am working on the right configuration file.– ddc
Jan 7 at 9:52
No, I am not editing these files, when server running. I don't know where another logging config can be there in deployment, could you please tell me in which directory it can be in wildfly server. Thing is when ever I change the logging config like
log level
from debug
to error
or <root-logger> <handlers>
from console
to FILE
in the standalone.xml file, the values are getting into effect and the log content is changing accordingly, so I am thinking that I am working on the right configuration file.– ddc
Jan 7 at 9:52
@JamesR.Perkins Thanks, I found where the another logging configuration file is in my application. There is a 'log4j.properties` file in
srcmainresources
folder. This file contains wrong file path configurations log4j.appender.file.File=XYZ.log
, due to which the log is being written in XYZ.log file located in wildfly bin directory. After changing this path to server.log log4j.appender.file.File=${jboss.server.log.dir}/server.log
the log is writing into server.log
file.– ddc
Jan 7 at 15:53
@JamesR.Perkins Thanks, I found where the another logging configuration file is in my application. There is a 'log4j.properties` file in
srcmainresources
folder. This file contains wrong file path configurations log4j.appender.file.File=XYZ.log
, due to which the log is being written in XYZ.log file located in wildfly bin directory. After changing this path to server.log log4j.appender.file.File=${jboss.server.log.dir}/server.log
the log is writing into server.log
file.– ddc
Jan 7 at 15:53
Ah yes that would do it. There is an attribute you can change to disable that. I'd also suggest using the web console or CLI to make changes as there would be no reason to shutdown the server first.
– James R. Perkins
Jan 7 at 17:37
Ah yes that would do it. There is an attribute you can change to disable that. I'd also suggest using the web console or CLI to make changes as there would be no reason to shutdown the server first.
– James R. Perkins
Jan 7 at 17:37
+1 I have single
wildfly server
in which I have to deploy multiple web applications, in this case, I believe I have to use different logging configuration file to each web application so that each application will have separate log file specific to that application. For this reason I am maintaining one more logging configuration file inside the application, along with standalone.xml
config.– ddc
Jan 10 at 10:44
+1 I have single
wildfly server
in which I have to deploy multiple web applications, in this case, I believe I have to use different logging configuration file to each web application so that each application will have separate log file specific to that application. For this reason I am maintaining one more logging configuration file inside the application, along with standalone.xml
config.– ddc
Jan 10 at 10:44
|
show 1 more comment
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54043204%2fslf4j-logging-not-printing-in-server-log-file-instead-it-is-printing-on-console%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54043204%2fslf4j-logging-not-printing-in-server-log-file-instead-it-is-printing-on-console%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Are you editing these files when the server is running? The console handler doesn't look assigned to anything so it should get nothing printed to it. Another possibility is you have a logging configuration file in your deployment.
– James R. Perkins
Jan 6 at 21:29
No, I am not editing these files, when server running. I don't know where another logging config can be there in deployment, could you please tell me in which directory it can be in wildfly server. Thing is when ever I change the logging config like
log level
fromdebug
toerror
or<root-logger> <handlers>
fromconsole
toFILE
in the standalone.xml file, the values are getting into effect and the log content is changing accordingly, so I am thinking that I am working on the right configuration file.– ddc
Jan 7 at 9:52
@JamesR.Perkins Thanks, I found where the another logging configuration file is in my application. There is a 'log4j.properties` file in
srcmainresources
folder. This file contains wrong file path configurationslog4j.appender.file.File=XYZ.log
, due to which the log is being written in XYZ.log file located in wildfly bin directory. After changing this path to server.loglog4j.appender.file.File=${jboss.server.log.dir}/server.log
the log is writing intoserver.log
file.– ddc
Jan 7 at 15:53
Ah yes that would do it. There is an attribute you can change to disable that. I'd also suggest using the web console or CLI to make changes as there would be no reason to shutdown the server first.
– James R. Perkins
Jan 7 at 17:37
+1 I have single
wildfly server
in which I have to deploy multiple web applications, in this case, I believe I have to use different logging configuration file to each web application so that each application will have separate log file specific to that application. For this reason I am maintaining one more logging configuration file inside the application, along withstandalone.xml
config.– ddc
Jan 10 at 10:44