Application specific logs not getting generated in JBoss EAP 7.3.0 - spring-boot

I have developed an application using Spring Boot and deployed that in JBoss EAP 7.3.0server. The application is writing the application specific logs in a separate log file (not server.log of JBoss) and we are using log4j for logging. The name and path where the lo would be generated is specified in log4j.properties placed in the classpath of the application. This setup is working correctly and logs are getting generated in one of our environments but logs are not getting generated in another environment. We are suspecting that the logger is not defined in JBoss in the environment where the logs are not getting generated. Can anyone please say from where to check the logger configuration of JBoss and how to ensure whether all the configurations are correct so that the logs will get generated?
Note: The JBoss server.log is getting generated correctly in all the environments.

Related

log4j2 behaviour different between tomcat 8.5.83 and 8.5.39

We have our web app running on tomcat 8.5.39. This app is using log4j2 correctly, applying a system property before log4j2 starts to indicate the log4j.xml configuration file. Something like:
System.setProperty("log4j.configurationFile", "/opt/ventusproxy/logs");
Now we have migrated to tomcat 8.5.83, and after this our webapp is not able to find the configuration file. Asking the log4j team, and after checking log4j debug file, it seems that, for any reason, log4j2 is starting before we set the previous system property.
We also tried 8.5.79 with the same result.
Is there any configuration change that we are missing between 8.5.39 and a later tomcat version that breaks the way log4j2 was working into our webapp until now?
Thanks,
Joan.

Spring Log4j2 xml file location

using Spring 2.0.5 with Log4j2
Have found works as expected if I place the file log4j2.xml in the resources folder.
However, have found the log4j2 option of monitorInterval="60" to be super useful as if some production issue can increase logging on some class without a restart. However if log4j2.xml is embedded in the jar of course it cannot be modified. so far the best I have been able to do is use 2 copies of log4j2.xml one in the resources and the other in the folder running the jar from.
I can then run:
java -Dlog4j.configurationFile=log4j2.xml -jar myapp.jar
it seems to work the same if started from the maven spring-boot plugin or from Eclipse.
Have tried a number of things such as setting the classpath, the absolute file name etc. but no luck
My question is how can I remove the log4j2.xml file from the resources folder and only specify it on the command line when starting spring?
I am not entirely clear on your question but I can provide the following information which I hope addresses it:
Log4j 2.12.0 added support for Spring Cloud Config and enhanced the support for Spring Boot. As of that version you can include a file named log4j2.system.properties and place any system properties you want defined there. They will be set before Log4j initializes. So you can specify the full URL to the configuration there if you want instead of the command line. You can also add the definition to a file named log4j2.component.properties.
The support for Spring Cloud Config allows you to place the configuration in your Spring Cloud Config server. See Spring CLoud Config support for more details.
Spring Boot initializes logging at least 3 times. The first is usually because the SpringApplication class declares a Logger so logging is initialized before anything else happens. The configuration for that will use "normal" log4j 2 initialization. After that Spring influences how logging initialization occurs primarily because Spring Boot sets the class path to include the jars inside BOOT-INF/lib directory inside your Spring Boot jar.
By using one of the configuration options I outlined above you can move the logging configuration outside of your application and you should not require a logging configuration in the resources directory. In fact, if you look at the sample Spring Cloud Config Application in Log4j you will see it does not include a configuration file in it.

Which are the easiest steps to enable log4j in a JAVA EE 7 (WAR) deployed on WildFly 10?

Everytime I don't use a template or have to upgrade old projects I get in troubles finding which is the easiest way to configure log4j for a WAR (EE 7) that will be deployed on WildFly 10...
I'm using maven
Can anyone help me ?
Thanks in Advance
I'd suggesting leaving the log4j.xml out of the deployment and configuring logging through the logging subsystem. This would allow you to make changes to the configuration at runtime without requiring a redeploy of the application or reload of the server.
For example to add a new logger with the DEBUG level in CLI:
/subsystem=logging/logger=org.jboss.as:add(level=DEBUG)
If you now need want to change it to TRACE logging:
/subsystem=logging/logger=org.jboss.as:write-attribute(name=level, value=TRACE)
You can also configure all this through the web console or the HTTP management API as well.

log4j logger statements are not displayed in jboss wildfly AS

I have added log4j.properties and included relevant log 4j entries in pom.xml in spring mvc web application. But , the logger statements are displayed neither in the eclipse ( which is configured with jboss wildfly AS ) console or server log.
Just removed the log4j.properties file from the web application & surprisingly see JBoss WildFly AS takes care of printing the logger statements in the eclipse console as well as server log.

Spring Boot - logging configuration from JBoss

I'd like to know if there is a way to configure Spring Boot logging using JBoss standalone.xml or domain.xml configuration. For now I ended up with two empty files log4j.properties and log4j-file.properties under org\springframework\boot\logging\log4j package in mvn resources in WAR file and it looks like now my logging configuration in domain.xml works because I've overriden default spring-boot log4j configuration.
But there must be a better way to do this instead of this stupid hack. Keep in mind that I don't want to provide external log4j properties file and set it for one of the property in application.properties but I want to use jboss logging system configuration.
EDIT
Strange thing but when I updated Spring Boot to version 1.4.0 then JBoss intercepts the logs and log them only to the file and I don't have logs on the stdout anymore even without custom log4j configuration.

Resources