You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Alex Smith <a....@gmail.com> on 2025/02/28 19:03:03 UTC

Issues Migrating Log4J 1.27 to Log4j2

I'm not sure I'm in the right place, but I've been working on migrating
from Log4j to Log4j 2 in a project I'm working on.

In the pom.xml, I removed the log4j dependencies and added the log4j
compatibility API to hte dependencies. I think some of of the other
dependencies I'm using may still be on log4j 1.2, but am not 100% certain
of this.

What I'm observing is that trying to add
import org.apache.logging.logj4.x is frequently throwing errors related to
ClassNotFoundException, and when attempt to build some of the services, I
get amongst others, the following errors

"StatusLogger Log4j2 could not find a logging implementation please add
log4j-core to the classpath... "
and
"Invocation of init method failed; nested exception is
java.lang.NoClassDefFoundError: org/apache/logging/log4j/core/logEvent"

As mentioned above, log4j-core is listed as a dependency in the pom.xml
file, so I can't imagine why the files wouldn't be found in the classpath.

I've been following the instructions from
https://logging.apache.org/log4j/2.x/migrate-from-log4j1.html, and am
struggling to find any information as to why the errors listed above might
be caused. If anyone has any insight on this or how to potentially resolve
it, I'd be extremely grateful.

I think I've supplied all the relevant information, but if there's anything
I'm missing I can easily look into it and provide whatever I find.

Thanks,
Alex

RE: Issues Migrating Log4J 1.27 to Log4j2

Posted by "McManamey, Tim" <Ti...@nebraska.gov.INVALID>.
Iirc syntax changed between those versions. It's worth understanding how it works. Also look at any deprecations. I'm not sure what the converter does with those items.

God bless,

Tim McManamey | IT Applications Developer/Senior
INFORMATION SYSTEMS & TECHNOLOGY
Nebraska Department of Health and Human Services
OFFICE: 402-471-9091
DHHS.ne.gov  |  Facebook  |  Twitter  |  LinkedIn


-----Original Message-----
From: Alex Smith <a....@gmail.com>
Sent: Monday, March 3, 2025 9:08 AM
To: Log4J Users List <lo...@logging.apache.org>
Subject: Re: Issues Migrating Log4J 1.27 to Log4j2

[You don't often get email from a.slonim24@gmail.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

Addendum:
For converting to the configuration files, I found some instructions on this page
https://logging.apache.org/log4j/2.x/migrate-from-log4j1.html#configuration-file-migration
related to running the command
java org.apache.log4j.config.Log4j1ConfigurationConverter \ --in log4j.properties --out log4j2.xml but it does not provide instructions on where to run this. Trying to run it from terminal throws class not found exception log4j1configruationconverter, despite having the artifacts log4-api, log4j-core and log4j-1-2.api in the pom.xml.

Thank you again,
Alex

On Mon, Mar 3, 2025 at 9:52 AM Alex Smith <a....@gmail.com> wrote:

> Unfortunately, as this is an enterprise product, I can't share those
> files. If there is specific information you are looking for from them,
> I may be able to provide an excerpt with pertinent information
> redacted/removed.
> To the other questions,
> Migrating to lo4j2 version 2.20.0
> Open JDK 17.0.14
> OS: Amazon Linux version 2023, ID like Fedora 2023
>
> W/r/t the log4j configuration, it appears we're using multiple
> log4j.xml files, some of which are log4j2 and otheru sing log4j, so I
> don't think they have been converted. Is there a page I can reference
> with instructions on how to convert those files?
>
> Thank you for the help,
> Alex
>
>
> On Sun, Mar 2, 2025 at 10:15 AM Volkan Yazıcı <vo...@yazi.ci> wrote:
>
>> Hey Alex,
>>
>> You're at the right place to ask Log4j-related questions. Would you
>> mind providing a little bit more information about your setup, please?
>>
>>    1. Which Log4j 2 version are you migrating to?
>>    2. Which OS and JDK distribution are you using?
>>    3. Is this a standalone or a JEE/Jakarta application?
>>    4. I presume you converted your Log4j 1 configuration to Log4j 2. Could
>>    you share your Log4j configuration? (e.g., `log4j2.xml`)
>>    5. Could you share your `pom.xml` file?
>>    6. Could you share your application logs when you start the application
>>    with the `log4j2.debug` system property?
>>
>> Kind regards.
>>
>> On Fri, Feb 28, 2025 at 8:03 PM Alex Smith <a....@gmail.com> wrote:
>>
>> > I'm not sure I'm in the right place, but I've been working on
>> > migrating from Log4j to Log4j 2 in a project I'm working on.
>> >
>> > In the pom.xml, I removed the log4j dependencies and added the
>> > log4j compatibility API to hte dependencies. I think some of of the
>> > other dependencies I'm using may still be on log4j 1.2, but am not
>> > 100%
>> certain
>> > of this.
>> >
>> > What I'm observing is that trying to add import
>> > org.apache.logging.logj4.x is frequently throwing errors related
>> to
>> > ClassNotFoundException, and when attempt to build some of the
>> > services,
>> I
>> > get amongst others, the following errors
>> >
>> > "StatusLogger Log4j2 could not find a logging implementation please
>> > add log4j-core to the classpath... "
>> > and
>> > "Invocation of init method failed; nested exception is
>> > java.lang.NoClassDefFoundError: org/apache/logging/log4j/core/logEvent"
>> >
>> > As mentioned above, log4j-core is listed as a dependency in the
>> > pom.xml file, so I can't imagine why the files wouldn't be found in
>> > the
>> classpath.
>> >
>> > I've been following the instructions from
>> > https://l/
>> > ogging.apache.org%2Flog4j%2F2.x%2Fmigrate-from-log4j1.html&data=05%
>> > 7C02%7CTim.McManamey%40nebraska.gov%7Cd035044d04c348193c1408dd5a653
>> > d62%7C043207dfe6894bf6902001038f11f0b1%7C0%7C0%7C638766113045558061
>> > %7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMC
>> > IsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sda
>> > ta=0wKIK6z41zPF9fZHygKOg7Pf9LKFKVm%2FyyWCOkJ3Od8%3D&reserved=0, and
>> > am struggling to find any information as to why the errors listed
>> > above
>> might
>> > be caused. If anyone has any insight on this or how to potentially
>> resolve
>> > it, I'd be extremely grateful.
>> >
>> > I think I've supplied all the relevant information, but if there's
>> anything
>> > I'm missing I can easily look into it and provide whatever I find.
>> >
>> > Thanks,
>> > Alex
>> >
>>
>

Re: Issues Migrating Log4J 1.27 to Log4j2

Posted by Alex Smith <a....@gmail.com>.
Addendum:
For converting to the configuration files, I found some instructions on
this page
https://logging.apache.org/log4j/2.x/migrate-from-log4j1.html#configuration-file-migration
related to running the command
java org.apache.log4j.config.Log4j1ConfigurationConverter \ --in
log4j.properties --out log4j2.xml
but it does not provide instructions on where to run this. Trying to run it
from terminal throws class not found exception
log4j1configruationconverter, despite having the artifacts log4-api,
log4j-core and log4j-1-2.api in the pom.xml.

Thank you again,
Alex

On Mon, Mar 3, 2025 at 9:52 AM Alex Smith <a....@gmail.com> wrote:

> Unfortunately, as this is an enterprise product, I can't share those
> files. If there is specific information you are looking for from them, I
> may be able to provide an excerpt with pertinent information
> redacted/removed.
> To the other questions,
> Migrating to lo4j2 version 2.20.0
> Open JDK 17.0.14
> OS: Amazon Linux version 2023, ID like Fedora 2023
>
> W/r/t the log4j configuration, it appears we're using multiple log4j.xml
> files, some of which are log4j2 and otheru sing log4j, so I don't think
> they have been converted. Is there a page I can reference with instructions
> on how to convert those files?
>
> Thank you for the help,
> Alex
>
>
> On Sun, Mar 2, 2025 at 10:15 AM Volkan Yazıcı <vo...@yazi.ci> wrote:
>
>> Hey Alex,
>>
>> You're at the right place to ask Log4j-related questions. Would you mind
>> providing a little bit more information about your setup, please?
>>
>>    1. Which Log4j 2 version are you migrating to?
>>    2. Which OS and JDK distribution are you using?
>>    3. Is this a standalone or a JEE/Jakarta application?
>>    4. I presume you converted your Log4j 1 configuration to Log4j 2. Could
>>    you share your Log4j configuration? (e.g., `log4j2.xml`)
>>    5. Could you share your `pom.xml` file?
>>    6. Could you share your application logs when you start the application
>>    with the `log4j2.debug` system property?
>>
>> Kind regards.
>>
>> On Fri, Feb 28, 2025 at 8:03 PM Alex Smith <a....@gmail.com> wrote:
>>
>> > I'm not sure I'm in the right place, but I've been working on migrating
>> > from Log4j to Log4j 2 in a project I'm working on.
>> >
>> > In the pom.xml, I removed the log4j dependencies and added the log4j
>> > compatibility API to hte dependencies. I think some of of the other
>> > dependencies I'm using may still be on log4j 1.2, but am not 100%
>> certain
>> > of this.
>> >
>> > What I'm observing is that trying to add
>> > import org.apache.logging.logj4.x is frequently throwing errors related
>> to
>> > ClassNotFoundException, and when attempt to build some of the services,
>> I
>> > get amongst others, the following errors
>> >
>> > "StatusLogger Log4j2 could not find a logging implementation please add
>> > log4j-core to the classpath... "
>> > and
>> > "Invocation of init method failed; nested exception is
>> > java.lang.NoClassDefFoundError: org/apache/logging/log4j/core/logEvent"
>> >
>> > As mentioned above, log4j-core is listed as a dependency in the pom.xml
>> > file, so I can't imagine why the files wouldn't be found in the
>> classpath.
>> >
>> > I've been following the instructions from
>> > https://logging.apache.org/log4j/2.x/migrate-from-log4j1.html, and am
>> > struggling to find any information as to why the errors listed above
>> might
>> > be caused. If anyone has any insight on this or how to potentially
>> resolve
>> > it, I'd be extremely grateful.
>> >
>> > I think I've supplied all the relevant information, but if there's
>> anything
>> > I'm missing I can easily look into it and provide whatever I find.
>> >
>> > Thanks,
>> > Alex
>> >
>>
>

Re: Issues Migrating Log4J 1.27 to Log4j2

Posted by Alex Smith <a....@gmail.com>.
Unfortunately, as this is an enterprise product, I can't share those files.
If there is specific information you are looking for from them, I may be
able to provide an excerpt with pertinent information redacted/removed.
To the other questions,
Migrating to lo4j2 version 2.20.0
Open JDK 17.0.14
OS: Amazon Linux version 2023, ID like Fedora 2023

W/r/t the log4j configuration, it appears we're using multiple log4j.xml
files, some of which are log4j2 and otheru sing log4j, so I don't think
they have been converted. Is there a page I can reference with instructions
on how to convert those files?

Thank you for the help,
Alex


On Sun, Mar 2, 2025 at 10:15 AM Volkan Yazıcı <vo...@yazi.ci> wrote:

> Hey Alex,
>
> You're at the right place to ask Log4j-related questions. Would you mind
> providing a little bit more information about your setup, please?
>
>    1. Which Log4j 2 version are you migrating to?
>    2. Which OS and JDK distribution are you using?
>    3. Is this a standalone or a JEE/Jakarta application?
>    4. I presume you converted your Log4j 1 configuration to Log4j 2. Could
>    you share your Log4j configuration? (e.g., `log4j2.xml`)
>    5. Could you share your `pom.xml` file?
>    6. Could you share your application logs when you start the application
>    with the `log4j2.debug` system property?
>
> Kind regards.
>
> On Fri, Feb 28, 2025 at 8:03 PM Alex Smith <a....@gmail.com> wrote:
>
> > I'm not sure I'm in the right place, but I've been working on migrating
> > from Log4j to Log4j 2 in a project I'm working on.
> >
> > In the pom.xml, I removed the log4j dependencies and added the log4j
> > compatibility API to hte dependencies. I think some of of the other
> > dependencies I'm using may still be on log4j 1.2, but am not 100% certain
> > of this.
> >
> > What I'm observing is that trying to add
> > import org.apache.logging.logj4.x is frequently throwing errors related
> to
> > ClassNotFoundException, and when attempt to build some of the services, I
> > get amongst others, the following errors
> >
> > "StatusLogger Log4j2 could not find a logging implementation please add
> > log4j-core to the classpath... "
> > and
> > "Invocation of init method failed; nested exception is
> > java.lang.NoClassDefFoundError: org/apache/logging/log4j/core/logEvent"
> >
> > As mentioned above, log4j-core is listed as a dependency in the pom.xml
> > file, so I can't imagine why the files wouldn't be found in the
> classpath.
> >
> > I've been following the instructions from
> > https://logging.apache.org/log4j/2.x/migrate-from-log4j1.html, and am
> > struggling to find any information as to why the errors listed above
> might
> > be caused. If anyone has any insight on this or how to potentially
> resolve
> > it, I'd be extremely grateful.
> >
> > I think I've supplied all the relevant information, but if there's
> anything
> > I'm missing I can easily look into it and provide whatever I find.
> >
> > Thanks,
> > Alex
> >
>

Re: Issues Migrating Log4J 1.27 to Log4j2

Posted by Volkan Yazıcı <vo...@yazi.ci>.
Hey Alex,

You're at the right place to ask Log4j-related questions. Would you mind
providing a little bit more information about your setup, please?

   1. Which Log4j 2 version are you migrating to?
   2. Which OS and JDK distribution are you using?
   3. Is this a standalone or a JEE/Jakarta application?
   4. I presume you converted your Log4j 1 configuration to Log4j 2. Could
   you share your Log4j configuration? (e.g., `log4j2.xml`)
   5. Could you share your `pom.xml` file?
   6. Could you share your application logs when you start the application
   with the `log4j2.debug` system property?

Kind regards.

On Fri, Feb 28, 2025 at 8:03 PM Alex Smith <a....@gmail.com> wrote:

> I'm not sure I'm in the right place, but I've been working on migrating
> from Log4j to Log4j 2 in a project I'm working on.
>
> In the pom.xml, I removed the log4j dependencies and added the log4j
> compatibility API to hte dependencies. I think some of of the other
> dependencies I'm using may still be on log4j 1.2, but am not 100% certain
> of this.
>
> What I'm observing is that trying to add
> import org.apache.logging.logj4.x is frequently throwing errors related to
> ClassNotFoundException, and when attempt to build some of the services, I
> get amongst others, the following errors
>
> "StatusLogger Log4j2 could not find a logging implementation please add
> log4j-core to the classpath... "
> and
> "Invocation of init method failed; nested exception is
> java.lang.NoClassDefFoundError: org/apache/logging/log4j/core/logEvent"
>
> As mentioned above, log4j-core is listed as a dependency in the pom.xml
> file, so I can't imagine why the files wouldn't be found in the classpath.
>
> I've been following the instructions from
> https://logging.apache.org/log4j/2.x/migrate-from-log4j1.html, and am
> struggling to find any information as to why the errors listed above might
> be caused. If anyone has any insight on this or how to potentially resolve
> it, I'd be extremely grateful.
>
> I think I've supplied all the relevant information, but if there's anything
> I'm missing I can easily look into it and provide whatever I find.
>
> Thanks,
> Alex
>