I have a problem with logback + wildfly 8 configuration.
I'm using simple ConsoleAppender:
appender("STDOUT", ConsoleAppender) {
encoder(PatternLayoutEncoder) {
pattern = "%d{HH:mm:ss.SSS} [%thread] %-5level %logger{70} - %msg%n"
}
}
logger("com.package.app", INFO)
root(DEBUG, ["STDOUT"])
The problem is that Wildfly appends to logback messages also server's log pattern.
It looks like:
11:31:49,954 INFO [stdout] (default task-1) 11:31:49.951 [default task-1] INFO com.package.app.controller.FrontController - message...
As You can see, there is a server logs pattern first and then the logback message
How to solve this problem?
WildFly captures System.out and System.err and redirects them to a logger. You could configure a logger in WildFly with the name stdout, set the use-parent-handlers attribute to false and set the level to NONE. This should disable System.out from printing which means it will also not appear in the server.log.
That said, I don't see a reason to use logback for a ConsoleAppender since the server already provides one.
Related
How do I setup logging.properties to log diverts in artemis.log?
I understand that TRACE should be used for org.apache.activemq.artemis.core.server.impl.DivertImpl
How do I set it up in etc/logging.properties?
To enable a particular logger (e.g. org.apache.activemq.artemis.core.server.impl.DivertImpl) in logging.properties you must first add the logger to the loggers list at the top of the file. Here is the default loggers list with org.apache.activemq.artemis.core.server.impl.DivertImpl added:
loggers=org.eclipse.jetty,org.jboss.logging,org.apache.activemq.artemis.core.server,org.apache.activemq.artemis.utils,org.apache.activemq.artemis.journal,org.apache.activemq.artemis.jms.server,org.apache.activemq.artemis.integration.bootstrap,org.apache.activemq.audit.base,org.apache.activemq.audit.message,org.apache.activemq.audit.resource,org.apache.activemq.artemis.core.server.impl.DivertImpl
Then you need to configure the logging level for the logger to TRACE, e.g.:
logger.org.apache.activemq.artemis.core.server.impl.DivertImpl.level=TRACE
Lastly, you need to update the level of the necessary handler to allow the TRACE logging through, e.g.:
handler.CONSOLE.level=TRACE
or
handler.FILE.level=TRACE
My logs are getting hammered by below log message in JBOSS 7. Can you anyone suggest how to stop this log message.
2018-02-28 13:37:13,618 WARN [com.arjuna.ats.arjuna] (default-threads - 48) ARJUNA012141: Multiple last resources have been added to the current transaction. This is transactionally unsafe and should not be relied upon. Current resource is LastResourceRecord(XAOnePhaseResource(LocalXAResourceImpl#5d70439b[connectionListener=653eac5d connectionManager=7f6856e8 warned=false currentXid=null productName=MySQL productVersion=10.2.13-MariaDB-log jndiName=java:/jdbc/db_jndi]))
In your standalone.xml file, in the logging section, add something like this under the appropriate handler element:
<filter>
<not>
<match pattern="ARJUNA012141"/>
</not>
</filter>
Of course, you should add these lines using the jboss-cli utility. Did you know that changes to logging don't require a server restart, but will be picked up at the defined refresh interval?
I deployed usergrid in tomcat, I see it is using slf4j binds to log4j, I tried to put log4j.properties in /var/lib/tomcat7/webapps/ROOT/WEB-INF/classes$ , but still not seeing log file created? anyone could help?
Usergrid is here, github.com/apache/incubator-usergrid
I built it myself and put the ROOT.war in tomcat /var/lib/tomcat7/webapps/, trying to enable logs in usergrid, I see a lot of log.info in usergrid's code, then I put log4j.properties in /var/lib/tomcat7/webapps/ROOT/WEB-INF/classes, but log file is not created
# Root logger option
log4j.rootLogger=INFO, file
# Direct log messages to a log file
log4j.appender.file=org.apache.log4j.RollingFileAppender
#Redirect to Tomcat logs folder
log4j.appender.file.File=${catalina.home}/logs/logging.log
log4j.appender.file.MaxFileSize=10MB
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
I've been able to configure Log4j logging in Usergrid by adding the following to Tomcat's CATALINA_OPTS environment variable:
-Dlog4j.configuration=file:/${path}/log4j.properties
Where ${path} is the path to your Log4j properties file.
As the title say, I created a class in the war layer that is annotated with #Picketlink. Note that I have an ear deployment structure (ejb, war).
The custom authenticator:
#PicketLink
public class PicketlinkAuthenticator extends BaseAuthenticator { }
If I put that class in the ejb layer, the authentication is ok but when I put it to the war layer it seems like it's not found by the project as it's throwing:
20:49:46,027 INFO [org.picketlink.common] (default task-10) Using logger implementation: org.picketlink.common.DefaultPicketLinkLogger
20:49:46,043 INFO [org.picketlink.idm] (default task-10) PLIDM001000: Bootstrapping PicketLink Identity Manager
20:49:46,068 WARN [org.picketlink.idm] (default task-10) PLIDM001101: Working directory [\tmp\pl-idm] is marked to be always created. All your existing data will be lost.
20:49:46,111 INFO [org.picketlink.idm] (default task-10) PLIDM001100: Using working directory [\tmp\pl-idm].
20:49:46,127 DEBUG [org.picketlink.idm] (default task-10) No partitions to load from \tmp\pl-idm\pl-idm-partitions.db
20:49:46,152 DEBUG [org.picketlink.idm] (default task-10) Initializing Partition [6a373282-0173-4b7d-bd6a-ff0e5dc43436] with id [6a373282-0173-4b7d-bd6a-ff0e5dc43436].
20:49:46,153 DEBUG [org.picketlink.idm] (default task-10) Loaded Agents for Partition [6a373282-0173-4b7d-bd6a-ff0e5dc43436].
20:49:46,154 DEBUG [org.picketlink.idm] (default task-10) Loaded Credentials for Partition [6a373282-0173-4b7d-bd6a-ff0e5dc43436].
Why not just move the authenticator to the ejb side?
->Because I'm throwing custom error like user expired, etc. I need jsf to post these error messages.
Why not move the picketlink dependency in the web layer?
->Because my account that extended the picketlink account is binded to my services.
As suggested here I already added the picketlink module in the war project:
https://docs.jboss.org/author/display/PLINK/JBoss+Modules
<jboss-deployment-structure>
<ear-subdeployments-isolated>false</ear-subdeployments-isolated>
<sub-deployment name="THE-WAR-MODULE-THAT-REQUIRES-PICKETLINK.war">
<dependencies>
<module name="org.picketlink" />
</dependencies>
</sub-deployment>
</jboss-deployment-structure>
Anyway around this? I just want to show some custom errors :-(
I was not able to solve this problem but I have a work-around solution and that is to move the picketlink module to the web layer and just pass the identity instance to the services that need it.
I have been missing around with the same problem as well for a while now (it's 2016 now ...). What seems to make it work is to add the following CDI annotations:
#PicketLink
#Name
#RequestScoped
public class PicketlinkAuthenticator extends BaseAuthenticator { }
I would have expected the core Authentication Manager to pick this up just based on the #PicketLink Annotation, but without the CDI Annotations, the custom Authenticator class is never even loaded. Maybe there is an other way that will require us to bootstrap PicketLink - but I could not find any references.
I am using log4j-gwt aud gwt's remote logging. I get the messages logged on my console as expected but did not managed to get the message print on my physical .log file.
Any idea of how I can do this?
Here is my log4j properties file (which works fine for all non-gwt related messages):
# CONSOLE APPENDER CONFIG [common] ---------------------------------------------------------------
log4j.appender.CONSOLE_APPENDER=org.apache.log4j.ConsoleAppender
#log4j.appender.CONSOLE_APPENDER.layout=org.apache.log4j.SimpleLayout
log4j.appender.CONSOLE_APPENDER.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE_APPENDER.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
# ROOT LOGGER CONFIG ----------------------------------------------------------------------
log4j.rootLogger=DEBUG,ROOT_FILE_APPENDER
log4j.appender.ROOT_FILE_APPENDER=org.apache.log4j.RollingFileAppender
log4j.appender.ROOT_FILE_APPENDER.File=C:/log/tbps_root.log
log4j.appender.ROOT_FILE_APPENDER.MaxFileSize=20480KB
log4j.appender.ROOT_FILE_APPENDER.MaxBackupIndex=5
log4j.appender.ROOT_FILE_APPENDER.layout=org.apache.log4j.PatternLayout
log4j.appender.ROOT_FILE_APPENDER.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
# GWT -------------------------------------------------------------------------------------
#These are various unseccsful attemps...
log4j.logger.com.google.gwt.logging.server.RemoteLoggingServiceUtil=DEBUG,ROOT_FILE_APPENDER
log4j.logger.com.google.gwt.logging.server.RemoteServiceServlet=DEBUG,ROOT_FILE_APPENDER
log4j.logger.com.google.gwt.logging.server.simpleRemoteHandler=DEBUG,ROOT_FILE_APPENDER
log4j.logger.com.google.gwt.logging=DEBUG,ROOT_FILE_APPENDER
log4j.logger.com.google.gwt.logging.Logging=DEBUG,ROOT_FILE_APPENDER
log4j.logger.com.google.gwt.logging.server=DEBUG,ROOT_FILE_APPENDER
GWT-log4j and GWT's RemoteLoggingService use different loggers, as described here. Hence, your log4j properties are not being applied to GWT's remote logger.
You can either implement your own remote logging class, or use slf4j to "bridge" the two loggers.
I recently added logs of the user's actions to a GWT application. I first tried using GWT-log4j in conjunction with RemoteLoggingService and had this same issue. After reading the above link I created my own logger class -- this was particularly nice as I could pass data objects to the remote logger allowing me to serialize the state of the GWT application. This later became very useful :)