Re: Facing issue in while doing migration log4j 1.x to 2.x

2023-06-05 Thread Piotr P. Karwasz
Hi Nishu,
Sorry for the delay,

On Wed, 24 May 2023 at 06:47, Nishu Gupta 
wrote:> I did the set the `log4j1.compatibility` to `true` in the
custom properties.
>
> Do I need to use the log4j.xml while using the bridge jar? or I need to 
> convert to log4j2.xml as well?

My rule of thumb on this is for developers to use a `log4j2.xml`
configuration and leave to end users the possibility of using a
`log4j.xml`.
Converting from a restrictive Log4j 1.x configuration file to the more
powerful Log4j 2.x format is a one-time job. Unless you need custom
legacy components I don't see a reason not to do it.

On Wed, 31 May 2023 at 13:27, Nishu Gupta  wrote:
> Here is the log4j and lo4j2 xml.
>
> I need a help for how jms call trigger?
>
>   class="com.aba.package.MyProject"
>  provideUrl="abcde://abc.test.com:3226"
>  initialContextFactory="com.abc.naming.abcdeInitialContextFactory"
>  queueConnectionFactoryBindingName="abc.def.qwe.ms"
>  queueBinding="anc.def.create"
>  messageOnly="true"
>  username="abc"
>  password="abc">
> 
>
>threshold="INFO"
>   provideUrl="abcde://abc.test.com:3226"
>   initialContextFactory="com.abc.naming.abcdeInitialContextFactory"
>   queueConnectionFactoryBindingName="abc.def.qwe.ms"
>   queueBinding="anc.def.create"
>   messageOnly="true"
>   username="xyz"
>   password="xyz"
>   queueDeliveryMode="2">
> 

I am not an expert on JMS, but your configuration has many errors:

 * there is **no** "JMSQueue" plugin,
 * you use a lot of properties that do not exist (cf.
https://logging.apache.org/log4j/2.x/manual/appenders.html#JMSAppender
). E.g. `initialContextFactory` should be `factoryName`, `provideUrl`
should be `providerURL` and so on.

Piotr

-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org



Re: how to use log4j-to-jul with log4j-web

2023-06-05 Thread Jason Guild

Hi All:

Thank you all for your help and the good information about log4j-web and 
log4-core.


I already had my per-application logging configured in 
WEB-INF/logging.properties and all output is going to the same log file 
now that I've switched to log4j-to-jul.


Cheers,
Jason

On 6/2/2023 2:13 PM, Jason Guild wrote:
CAUTION: This email originated from outside the State of Alaska mail 
system. Do not click links or open attachments unless you recognize 
the sender and know the content is safe.


Hi All:

I have a web application that uses log4j (v2.20) which runs inside
Tomcat 9.x on Java 8.

Currently, the WEB-INF/log4j2.xml configuration file in the application
sends its output to a rolling file appender targeting a separate file on
the file system, but what I'd like to do is make all log4j output go to
the regular per-application log under ${catalina_base}/logs which is
managed by the stock Tomcat JULI implementation.

We now have the log4j-to-jul module which can adapt log4j 2 output back
to java.util.logging.
Similar to my understanding of the purpose for log4j-to-slf4j, it seems
that log4j-to-jul is meant to be used as an implementation by itself for
log4j-api and without log4j-core.

The application currently uses log4j-web to get the all the essential
setup for initializing log4j 2 under an application container. The
log4j-web library appears to have a hard dependency on log4j-core.

After adding log4j-to-jul to the application classpath, I can see that
it is recognized:

Multiple logging implementations found:
Factory: org.apache.logging.log4j.core.impl.Log4jContextFactory,
Weighting: 10
Factory: org.apache.logging.log4j.tojul.JULLoggerContextFactory,
Weighting: 20


But then the following error is reported:

ERROR StatusLogger LogManager returned an instance of
org.apache.logging.log4j.tojul.JULLoggerContextFactory which does not
implement org.apache.logging.log4j.core.impl.Log4jContextFactory.
Unable to initialize Log4j.


In org.apache.logging.core.config.Configurator, line 47 there is a
conditional that checks the return type of the logging implementation
is-a Log4jContextFactory. The problem is then that
JULLoggerContextFactory implements only LoggerContextFactory.

I'd like to keep my tomcat container as stock as possible. Particularly,
continuing to use the built-in JULI per-application logging and *not*
switching the entire container to use log4j as its logging 
implementation.


Can anyone suggest how I can use log4j-to-jul successfully for my use 
case?


Thanks,
Jason


-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org



--
Jason Guild
Systems Programmer
Alaska Department of Transportation & Public Facilities
Statewide Administrative Services
820 E. 15th Ave.
Anchorage, Alaska 99501