Преобразование из Log4j.xml в Log4j2.xml

Уважаемые люди из Stackru, мне нужна ваша помощь.

Я в настоящее время сижу на проекте, у которого есть log4j, и я хочу обновить его до log4j2. Причина этого в том, что я хочу внедрить профили пружин и отослать файлы журналов в совместимые конфигурации журналов среды.

Моя проблема в том, что я переместил файл log4j.xml из папки Resource и вместо этого вставил свой log4j2.xml. Однако приложение все еще ищет log4j.xml. Получение следующего сообщения с использованием Log4j.debug в командной строке.

log4j: Trying to find [log4j.xml] using context classloader sun.misc.Launcher$AppClassLoader@18b4aac2.
log4j: Trying to find [log4j.xml] using sun.misc.Launcher$AppClassLoader@18b4aac2 class loader.
log4j: Trying to find [log4j.xml] using ClassLoader.getSystemResource().
log4j: Trying to find [log4j.properties] using context classloader sun.misc.Launcher$AppClassLoader@18b4aac2.
log4j: Trying to find [log4j.properties] using sun.misc.Launcher$AppClassLoader@18b4aac2 class loader.
log4j: Trying to find [log4j.properties] using ClassLoader.getSystemResource().
log4j: Could not find resource: [null].
log4j:WARN No appenders could be found for logger (org.springframework.web.context.support.StandardServletEnvironment).
log4j:WARN Please initialize the log4j system properly.

Так что, очевидно, мое приложение все еще думает, что я пытаюсь использовать обычный log4j.

Я обновил свою зависимость от

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-log4j</artifactId>
</dependency>

в

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>

И я удалил все другие виды регистрации log4j в моем файле pom.xml. Кроме того, я исключил logback из зависимости spring-boot-starter.

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter</artifactId>
    <exclusions>
        <exclusion>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-logging</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
    <exclusions>
        <exclusion>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-logging</artifactId>
        </exclusion>
    </exclusions>
</dependency>

Вся помощь приветствуется. Если у меня есть ссылка на.jar мой собственный проект, который использует log4j, может ли это конфликтовать или я получу видимую ошибку?

0 ответов

Другие вопросы по тегам