Enable TRACE for a particular logger in ActiveMQ Artemis - activemq-artemis

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

Related

Using Actor Logging Via SLF4j and logback vs using org.slf4j to log using SLF4J and logback

I am confused with the best practice to use in logging. I found by reading that SLF4J removes the coupling between the application and logging API etc. So if i use actor logging, will it not be closely coupled to application?.I have also checked a lot of github codes and i noticed that they only use actor logging and not org.SLF4J.LoggerFactory logging. Why?
Some links which i referred
SACHA'S BLOG OF PROGRAMMATICALNESS
Another Good read
stack Overflow -> Checked the last answer
Thanks in advance
So we are in a new world, a world where we want to be reactive and non-blocking but some information before that.
Akka is using for logging SLF4j api that is a facade over common logging libraries i.e. log4j, logback, but does all of this async in order to not block actor.
So:
log.info("Received msg: {} use thread {} to dispatch", message, Thread.currentThread().getName());
in an actor where log is defined as:
LoggingAdapter log = Logging.getLogger(getContext().system(), this);
sends a logging message to logging actor, and the IO operations is actually done by this specialized actor.
Log4j or logback is only the implementation of actual logging, that's why you still need to configure one of if in your project.
log4j.appender.file.layout.ConversionPattern=[%d,%p] [%X{sourceThread}] [%c{1}.%M:%L] %m%n
%X{sourceThread} actually gives you the execution thread where the logging message was issued by original actor and not the thread that executes the IO operation inside logging actor (logged by %t) - more on this http://doc.akka.io/docs/akka/current/java/logging.html
My advice is to use log4j 2 since is using async operations and will not block the thread behind logging actor - more about log4j 2 performance on https://www.grobmeier.de/log4j-2-performance-close-to-insane-20072013.html

Logger log1-Slf4jLogger did not respond within Timeout(5000 milliseconds) to InitializeLogger(bus)

I am running an Akka application under Akka Kernel and the program works fine in other systems.
akka {
loggers = ["akka.event.slf4j.Slf4jLogger"]
loglevel = INFO
}
Which is the correct slf4jLogger configuration. However when I run my application it gives the following stack trace and fails to start.
[WARN] [01/12/2015 15:35:01.953] [main]
[EventStream(akka://ARCWorker)] Logger log1-Slf4jLogger did not
respond within Timeout(5000 milliseconds) to InitializeLogger(bus)
error while starting up loggers akka.ConfigurationException: Logger
specified in config can't be loaded [akka.event.slf4j.Slf4jLogger] due
to [akka.event.Logging$LoggerInitializationException: Logger
log1-Slf4jLogger did not respond with LoggerInitialized, sent instead
[TIMEOUT]] at
akka.event.LoggingBus$$anonfun$4$$anonfun$apply$1.applyOrElse(Logging.scala:116)
There is more to the stack trace which I can paste on demand.
Has anyone seen this error and how to get rid of this?
Thanks
Manas
You have to increase the timeout timer in your application.conf
akka.logger-startup-timeout = 30s
this solved the problem for me.

Why does Gate.init() call throws java.lang.NullPointerException?

I'm new to GATE, ANNIE & Info Extraction(IE). I'm trying to use ANNIE to do some IE. I installed GATE on Ubuntu 14.*, GATE Developer 8 worked perfectly. I'm trying to use GATE Embedded from my Java (JDK 1.8) project in Eclipse (Luna). I created a user library to add necessary GATE Jars (gate.jar & all jars in Lib) to build path. I added gate.home system property using
System.setProperty("gate.home", "/home/haree/GATE_Developer_8.0");
I tried the examples provided on GATE link, but I'm stuck with the following Null Pointer Exception which I couldn't fix.
Output:
Initialising GATE...
log4j:WARN No appenders could be found for logger (gate.Gate).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread "main" java.lang.NullPointerException
at gate.util.Files.getResource(Files.java:399)
at gate.util.Files.getGateResource(Files.java:419)
at gate.Gate.init(Gate.java:178)
at sheffield.examples.TestGate.main(TestGate.java:16)
I noticed that the Exception is caused by - Gate.init() method call. I wrote a simple class with a call to the above method and played with that system property(gate.home) etc but of no use. I somehow feel that the exception is caused when the GATE API is trying to read the gate.xml file which is in the installation directory. I copy that here as well along with code I wrote. Any help in fixing this is appreciated.
Code:
package sheffield.examples;
import gate.Gate;
import gate.util.GateException;
import gate.util.Out;
public class TestGate {
public static void main(String[] args) {
// initialise the GATE library
Out.prln("Initialising GATE...");
System.setProperty("gate.home", "/home/haree/GATE_Developer_8.0");
try {
Gate.init();
} catch (GateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Out.prln("...GATE initialised");
}
}
gate.xml file:
<?xml version="1.0"?>
<!-- gate.xml -->
<!-- $Id: gate.xml 17080 2013-11-12 19:29:34Z markagreenwood $ -->
<!-- any entries in this file will be processed at Gate.init()
time - i.e. will appear in every GATE invocation -->
<GATE>
<GATECONFIG Save_options_on_exit="true" Save_session_on_exit="true"/>
</GATE>
Note: I googled and found this link which discusses the same problem but it didn't help me
More Info:
I configured log4j which I ignored before and logs look like this:
Initialising GATE...
18:49:37 INFO [main] - gate.Gate.initLocalPaths - Using /home/haree/GATE_Developer_8.0 as GATE home
18:49:37 INFO [main] - gate.Gate.initLocalPaths - Using /home/haree/GATE_Developer_8.0/plugins as installed plug-ins directory.
18:49:37 INFO [main] - gate.Gate.initLocalPaths - Using /home/haree/GATE_Developer_8.0/gate.xml as site configuration file.
18:49:37 INFO [main] - gate.Gate.initLocalPaths - Using /home/haree/.gate.xml as user configuration file
18:49:37 INFO [main] - gate.Gate.initLocalPaths - Using /home/haree/.gate.session as user session file
Exception in thread "main" java.lang.NullPointerException
at gate.util.Files.getResource(Files.java:399)
at gate.util.Files.getGateResource(Files.java:419)
at gate.Gate.init(Gate.java:178)
at sheffield.examples.TestGate.main(TestGate.java:16)
I have read that GATE creates/ uses two configuration files in the user home directory namely: 1)gate.xml & 2)gate.session
I couldn't find both these files in the home directory for some reason (I'm new to Ubuntu file system), not sure if they are hidden files.
The issue has to do with the class loading in Eclipse, and I suspect it wouldn't be happening if you did it in IntelliJ or via the CLI (I tried it in IntelliJ Idea, and it worked fine.)
When you call
Gate.init();
It's stepping through a bunch of code that initializes it's state, and one of them tries to load a resource using the custom Gate class loader (in Files.getResource()). The class loader hasn't been initialized yet though, so it falls back to trying to load the resource using this:
return Files.class.getClassLoader().getResource(resourceName);
Which, in some cases (the Eclipse case, specifically), will return a null classloader. This is (I suppose) a bug in Gate, as they should fall back to the system classloader in this case.
This is the same issue as here: getClass().getClassLoader() is null, why?

how to write log4j-gwt messages into a file instead of console?

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 :)

Drools logging with logback

I'm using Drools 5.4.0.Final
For logging I'm using logback in my application.
I tried to add update my logback.xml with
<logger name="org.drools" level="debug"/>
But I see nothing in my logs concerning Drools.
I would expect to see so my lines of logs concerning the drools initialization.
You can pass the LOGGER to the StatefulKnowledgeSession
private static final Logger LOGGER = LoggerFactory.getLogger(Example.class);
private transient StatefulKnowledgeSession ksession;
.
.
.
ksession.setGlobal("logger", LOGGER);
and in your DRL file, you have to define global org.slf4j.Logger logger and then you can use the logger in your rules.
Drools 5.4.0.Final does not support any logging framework natively. The next version, Drools 5.5.0.Beta1, will. It will also be documented in the manual how to use it. See this issue for more info.
Drools 5.5.0.Beta1 will log to slf4j-api, so you can logback, log4j, jdk-logging, slf4j-simple, ... You still need to explicitly call KnowledgeRuntimeLoggerFactory.newConsoleLogger() and add that to the event listeners.