Log4j2 NoSQL Cassandra configuration in .properties file - cassandra

I'm trying to add an appender to Karaf 4.2, to log exceptions to Cassandra (DSE). My "org.ops4j.pax.logging.cfg" file looks like this:
log4j2.rootLogger.appenderRef.cassandrass.ref = Cassandra
# Cassandra Appender
log4j2.appender.cass.type=NoSql
log4j2.appender.cass.name=Cassandra
but it fails with
org.ops4j.pax.logging.pax-logging-api [log4j2] ERROR : NoSQL provider not specified for appender [Cassandra]. Ignored FQCN: org.apache.logging.log4j.spi.AbstractLogger
Null object returned for NoSql in Appenders. Ignored FQCN: org.apache.logging.log4j.spi.AbstractLogger
Unable to locate appender "Cassandra" for logger config "root" Ignored FQCN: org.apache.logging.log4j.spi.AbstractLogger
Almost every configuration example I find is in the xml format. Does anyone have a working example they can share? It is complaining "NoSQL provider not specified" which makes perfect sense. I just don't know how to configure the provider to be Cassandra
This is the guide I'm following: https://logging.apache.org/log4j/2.x/manual/appenders.html#CassandraAppender

It isn't clear in your post what you're trying to achieve. If you're attempting to configure logging for Cassandra, it won't work with Log4j.
Cassandra uses SLF4J with logback so you need to configure it accordingly. For details, see Configuring logging in Cassandra.
If you're using Log4j in your app, have a look at Configuring Log4j with a properties file. Cheers!

Related

Configuring Reportportal with Java +TestNG or Java + Log4j

Have been trying to configure Reportportal withe a sample project. The following steps have been done:
1.Start a Docker and get the reportporal page up and running.
2.In the Java project, added the bintray repository, java-agent-testng, logger-java-log4j dependencies.
3.Included log4j.properties file in the project and also the log4j.appender line for reprortportal
log4j.appender.reportportal=com.epam.ta.reportportal.log4j.appender.ReportPortalAppender
log4j.appender.reportportal.layout=org.apache.log4j.PatternLayout
log4j.appender.reportportal.layout.ConversionPattern=[%d{HH:mm:ss}] %-5p (%F:%L) - %m%n
4.Included log4j info lines for one of the #Test methods.
5.Ran the Test script and made sure the log info line is seen on the console.
6.However, the reportportal dashboard still shows "No Results Found"
7.Also, added the following line for the Test Method.
#Listeners({ReportPortalTestNGListener.class})
8. This threw an exception with Jackson.
A few questions running in my mind:
1.Do we need both TestNG and Log4j to integrate with reportportal or just one of them is fine.
2. With the above steps carried out, is there anything that has been missed. Why am I not seeing data on my reportportal dashboard.
I only did this using the testNG integration. We do have log4j but didn't needed that to post the tests in RP.
I do not however, have any screenshots or attachments.I think that is log4j integration.
#Chethan Swaroop
TestNG integration will send events as testStarted, testEnded into ReportPortal.
This will help to represent structure of test cases and statuses in RP.
Log4J integration (logger appender) will forward logs output into RP server, associating log line with active test case at the moment.
You can have only testNG integration, without logs (log4j), but you can't have log4j, without testing engine integration (testNG in you case)
Please try examples with you local ReportPortal instance:
https://github.com/reportportal/example-java-TestNG/tree/master/logback/src/main/java/com/epam/rp/tests

How do I redirect a 3rd partly log4j message to my own DailyRollingFileAppender?

I'm getting messages like this on my console from XMPP library Babbler:
Jun 08, 2015 9:10:11 PM rocks.xmpp.extensions.caps.EntityCapabilitiesManager$7 run
WARNING: Failed to discover information for entity 'foo#bar.com/User' for node 'http://...'
I would really like to redirect these messages to a DailyRollingFileAppender I already have for my own log4j logging, but I haven't figured out the correct log4j.xml incantation to make that happen. Does anyone have any suggestions other than "read the log4j docs?" I've been doing that and tinkering with settings, but nothing has helped so far.
It turns out Babbler was using java.util.logging. I upgraded my own logging from Log4J 1.2.17 to Log4J2 2.3, and then used the JUL bridge to capture and redirect the logging output from Babbler to Log4J2 RollingFile appender.

How do I programmatically disable Hazelcast client's logging?

I used to use networkConfig.setProperty("hazelcast.logging.type", "none") in cluster's network configuration, but I can't see any logging-related configuration methods in any of ClientConfig and ClientNetworkConfig. Please help to save my server's log files.
Hazelcast version: 3.2.5
I think you can do exactly the same thing on the ClientConfig using the ClientConfig.setProperty. Personally I never use it, I prefer to use the commandline option (-Dhazelcast.logging.type=blabla) because this give more predictable logging behavior.
I use Hazelcast with the default JDK logger.
This works for me to save my server's log files:
Logger logger = Logger.getLogger("");
logger.setLevel(Level.WARNING);

Log4j property in Jetty-9 logging framework

I am switching from jetty-7.6 to jetty-9.2.1. I am facing a issue where jetty server logs are not coming into the log file.
Previously with jetty-7.6:
I was running the server with:
"--ini OPTIONS=Server,jsp,jmx,resources,websocket,ext,plus,annotations" and setting the property : ("log4j.configuration", "/log4j/log4j.properties")
Now with the new version jetty-9.2.1:
I am running the jetty server with module option as:
"--module=server,jsp,deploy,jmx,resources,websocket,ext,plus,annotations" and also setting the same property for log4j : ("log4j.configuration", "/log4j/log4j.properties")
But I am not able to get jetty logs.
Is there anything I am missing or some configuration changes with new version ?
Thanks,
Anuj

log4j with liferay and tomcat

I have a Liferay setup on the Tomcat6. I used Log4j initially for portlets/webapps by adding log4j.properties file in the classes folder and log4j.jar file in the web-inf/lib.
Now we have few quartz jobs which are available in the tomcat/lib folder and I want to enable log4j logging for these jobs as well.
For these quartz jobs I have copied same log4j.properties file in the tomcat/lib.
With the new configuration I keep getting the following error:
Could not instantiate appender named "JOBS"
A "org.apache.log4j.RollingFileAppender" is not assignable a "org.apache.log4j.Appender" variable.
The class "org.apache.log4j.Appender" was loaded by ...
How to remove this error?
Is there any way I can keep a single log4j.properties file which can be used by both shared/lib as well as portlet/webapps.
According to this post the problem is that you have configured your log4j twice.
My solution would be that you create the logger instance like this
private static Logger logger = Logger.getLogger(FooBar.class.getName());
and not to have log4j.properties under any lib or class folder but having it under a folder named resources.
AFAIK this should be a place where the both parts of your application may have access to.
Known issue in Liferay: http://issues.liferay.com/browse/LPS-9376
In my case, the problem occurred once I started to use ServiceBuilder services, and added Log4J Logger to one of my ...LocalServiceImpl classes.
Once I removed Log4J logging from there everything got back to norm - exception disappeared.
(I made service methods throw exceptions, and was catching them in a code not related to ServiceBuilder read/generated classes, but it could also be done by changing Log4J logger calls to Liferay's LogUtil calls).

Resources