log4j extras in OSGi environment - log4j

I want to use the log4j-extras-1.1.jar in OSGi environment (Fuse Fabric 7.1.0.fuse-047)
so that I can use archive feature of org.apache.log4j.rolling.RollingFileAppender
What are simplest steps to achieve that?

It can't easily be done, and you actually don't need it. The used Pax-Logging provides a ZippedRollingFile appender out-of-the-box:
org.apache.log4j.zip. ZipRollingFileAppender

Related

Do I need to update log4j.properties file if I use the Log4j 1.x bridge (log4j-1.2-api)

I've followed the doc here : https://logging.apache.org/log4j/2.x/manual/migration.html
Also looked at https://logging.apache.org/log4j/2.x/manual/configuration.html#Properties
My existing log4j.properties only uses DailyRollingFileAppender, ConsoleAppender, both of which are under the 'Supported Components', so I shouldn't be forced to convert my log4j.properties file into log4j2.properties format. I'm not accessing methods and classes internal to the Log4j 1.x implementation, as suggested by the document.
For using the bridge, I previously was using both log4j1.compatibility and log4j.configuration, but the document suggests using 'any one' (tried using just one, doesn't work)
I can build my application successfully, however, my application no longer logs anything. What am I missing?
You may want to consider reload4j as a drop-in replacement for log4j 1.x. Initiated by Ceki Gülcü, the original author of Apache log4j 1.x, the reload4j project is a fork of Apache log4j version 1.2.17 with the goal of fixing pressing security issues.
The reload4j project offers a clear and easy migration path for the users who have an urgent need to fix vulnerabilities in log4j 1.2.17.
You don't need to update your properties file.
You can add a log4j2.component.properties file on the class path (in my case, in the same directory as my log4j.properties file) to set the log4j1.compatibility property, like this:
log4j1.compatibility=true
In our case, it only required setting the compatibility property and then it automatically picked up the log4j.properties file that was available on the class path.
Figured it out.
The answer lied in the Automatic Configuration section

Is there an equivalent to codehaus' plugin's <xsdPathWithinArtifact> for the maven-jaxb2-plugin?

jaxb2-maven-plugin has the <xsdPathWithinArtifact> option. Is there an equivalent in maven-jaxb2-plugin? What is the recommended way to include the schema file in the produced jar? I'm currently using Maven's native <resources>.
Disclaimer: I'm the author of the maven-jaxb2-plugin.
No, there is no such option in maven-jaxb2-plugin and there will not be. Managing resources is not the concern of maven-jaxb2-plugin, there are other Maven plugins for that.
The recommended way is exactly what you're doing - place your schemas under src/main/resources and they will be packaged in the resulting JAR.

Log4j NoSQL/Mongo appender in Tibco BusinessWorks 5

What Log4J version is Tibco BusinessWorks 5 using?
And can I use the NoSQL appenders in that version? Can it be done without installing the Log4J 1-2 bridge?
Later update: It seems that so far changing the Log4J configuration file does not have too much effect. See Changing Log4J configuration in Tibco BW/Designer does not have the desired effect.
You should be able to find it from below location of your TIBCO products installation.
Go to ../tibco/tpcl/<version>/lib and look for `log4j.jar
And you do not have to install log4j explicitly.
I believe, you should be able to add your required appender in the file ../tibco/bw/<version>/lib/log4j.properties. Also there is `lo4j.xml in case properties file does have worked. Try it out.
Just to complement Rao's response, you also need to add to restart your engines and make sure you added an appender to the right logger, namely bw.logger from either the log4j.properties or log4j.xmlfile.
This is not possible with internal Tibco logging. Only Java activities can use custom loggers.

how to define multiple log4j configs with Jetty server in web.xml

Here's what I want to do:
- being able to have separated log4j.properties for each different deployment "war"
- being able to define in ant build, or web.xml, using system parameter on which log properties to use.
My project setup is Jetty with Jersey as REST API, without Spring.
I've done some research and it turns there are other Spring solutions to set in webl.xml but I'm not using spring.
I also know Jetty is using slf4j but if switching to slf4j, would I be able to do this more easily?
What would be a best way to solve this, so that in web.xml or ant build, log4j config can be customized defined?
Thanks a lot!
EDIT:
I figured that I can start another servlet with some init-param defined. Then on a separated HttpServlet implementation to set the PropertyConfigurator.configure([name of the log4j config]);
Is this adding one more servlet an ideally way of handling this?
Lots of different ways to handle this.
Since your mission is not different logging per Servlet, or per Webapp...I wouldn't solve the problem in the servlet or webapp locations but at the server level. To me, you want to log all this information to the correct place, not just all the information once the servlet has been deployed. To this end, I would enable the slf4j-api support in jetty and then look into the best way to handle that from the slf4j side of things. With that you can use whatever logging framework you want, slf4j-simple, log4j or logback..whatever you like.
Alternatively, if you really want to avoid the server side of logging, I supposed you could just use a log4j.properties file in the resources directory and then on jetty startup on the command line serve out a different resources directory. Figure out what options you want and startup with:
java -jar start.jar OPTIONS=Server,jmx,jsp,resources-[dev,qa,prod]
cheers

Multiple log files using Log4j

I have a web application, that is build on spring webflow and jsf. Multiple users can log into my application at the same time. Now I want to use log4j to, of course, do the logging.
My question: is it possible to let log4j create different log files for every connected user?
thanks, Nikolaus
No, statically configured log4j cannot do it (unless your user set is constant and known upfront), you'd have to implement something on top of it that would set the configuration programatically.
If logback can do it, as fge says, use it, best not directly, but through slf4j.

Resources