slf4j

Customize SLF4J Logger

蓝咒 提交于 2019-12-13 02:15:06
问题 I'm trying to find a nice way to add a prefix to my logs without passing it on every calls, without instanciate Logger again. The purpose is to trace Rest calls individually. (The prefix would be re-generated on each call using UUID) This would be like @RestController class MyClass { //Here the prefix is initialise once //default value is X Logger LOG = LoggerFactory.getLogger(MyClass.class); @RequestMapping("/a") void methodA() { LOG.debug("foo"); } @RequestMapping("/b") void methodB() { LOG

WildFly 8 and Log4j 2’s log4j-web module

a 夏天 提交于 2019-12-13 01:13:54
问题 I am working on a web application that is running on WildFly and that is using SLF4J and Log4j 2 as logging system. On the Apache pages about Log4j 2 I read about the advantages of using the log4j-web module in a web application (Using Log4j 2 in Web Applications), so I added it and since then WildFly refuses the deployment (that is why I have commented it out in the listing below). So, here is my question: is it advisable to use the log4j-web module with WildFly and if so, how do I set it up

Issues replacing Log4j with LogBack, log4j-over-slf4j.jar shortcomings

為{幸葍}努か 提交于 2019-12-12 17:40:09
问题 So I've been porting some of our services to use Logback over log4j and I've been using the log4j-over-slf4j jar to spoof log4j for our legacy dependencies. The only issue is log4j-over-slf4j doesn't implement many of the classes of log4j so I'm seeing a decent few class not found exceptions from dependent jars. How have people got around this? Is it enough to just put the nlog4j in your classpath instead of the log4j-over-slf4j jar? I haven't tested this last idea yet but I'm planning on it

maven java.lang.IllegalAccessError: tried to access method com.google.common.collect.MapMaker.makeComputingMap

雨燕双飞 提交于 2019-12-12 17:21:29
问题 Hi I'm getting this error in eclipse running maven using m2eclipse, same error happens with any maven functionality (install, clean, ect.) Exception in thread "main" java.lang.IllegalAccessError: tried to access method com.google.common.collect.MapMaker.makeComputingMap(Lcom/google/common/base/Function;)Ljava/util/concurrent/ConcurrentMap; from class com.google.inject.internal.Annotations$AnnotationChecker at com.google.inject.internal.Annotations$AnnotationChecker.<init>(Annotations.java:104

Logging error on WAR Deploy with Tomcat7, Apache Wink, and Mongo DB

一个人想着一个人 提交于 2019-12-12 14:28:53
问题 I am having problems deploying my application onto my tomcat server. I get the following trace every time I deploy it: 27-Oct-2013 17:02:34 org.apache.catalina.startup.HostConfig deployWAR INFO: Deploying web application archive /var/lib/tomcat7/webapps/JsonTest.war Handler error java.io.IOException: Couldn't get lock for %h/java%u.log at java.util.logging.FileHandler.openFiles(FileHandler.java:389) at java.util.logging.FileHandler.<init>(FileHandler.java:225) at sun.reflect

slf4j warning about the same binding being duplicate

微笑、不失礼 提交于 2019-12-12 12:02:55
问题 SLF4J complains about multiple bindings, but those look exactly the same: SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [zip:C:/bea_domains/my_service_domain/servers/AdminServer/tmp/_WL_user/my-shared-app-lib/obaz3z/APP-INF/lib/slf4j-log4j12-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [zip:C:/bea_domains/my_service_domain/servers/AdminServer/tmp/_WL_user/my-shared-app-lib/obaz3z/APP-INF/lib/slf4j-log4j12-1.6.1.jar!/org/slf4j/impl

PlayFramework Multiple SLF4J bindings

孤街浪徒 提交于 2019-12-12 11:32:49
问题 I'm trying to complete some basic unit tests of some models. However I'm getting the following error. Now it appears I have two bindings for SLF4J. This is because I am using Mahout which has one version of SLF4J and Play has its own version. Can anyone tell me how I can resolve this problem? SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Detected both jcl-over-slf4j.jar AND slf4j-jcl.jar on the class path, preempting StackOverflowError. SLF4J: See

OpenJPA logging with slf4j on WebSphere

こ雲淡風輕ζ 提交于 2019-12-12 10:55:36
问题 My Java EE 6 application uses slf4j with logback as logging framework. Now I want to add the SQL traces of OpenJpa to my log files. The OpenJpa-Documentation says, I can use a parameter to this: <property name="openjpa.Log" value="slf4j"/> I use the WebSphere Application Server v8.0.0.1 as Java EE container. If I deploy my application to the server, this parameter does not change anything. I can change log levels in WebSphere Admin Console and this works fine. But a cannot bypass the OpenJpa

Slf4j with Log4j does not print wrapped exception (caused by) when wrapper exception has a message

[亡魂溺海] 提交于 2019-12-12 10:43:56
问题 First example: public class Main { private static final Logger logger = LoggerFactory.getLogger(Main.class); public static void main(String[] args) throws Exception { try { throw new RuntimeException(new NullPointerException("NPE")); } catch (RuntimeException e) { logger.error("Error:", e); } } } Output: Error: java.lang.RuntimeException: java.lang.NullPointerException: NPE at Main.main(Main.java:10) In the second example we just add a message to the RuntimeException also: throw new

Dynamically add appender with slf4j and log4j2

不想你离开。 提交于 2019-12-12 09:31:30
问题 I want to dynamically create an appender and add it to a logger. However, this seems not to be possible with slf4j. I can add my appender to a log4j logger but then I fail to retrieve the logger with the slf4j LoggerFactoy. What I want to do: I create a test class (not a jUnit test) and pass a logger in the constructor for the test class to use. Every instance of the test class needs it's own logger and appender that saves the log so it can be later used in an HTML report. What I tried (for