Tell me please, how to write path to file inside the maven dependency with my custom configuration in <xi:include href=""
in log4j2 configuration?
In my application I've added following maven dependency:
<dependency>
<groupId>logging</groupId>
<artifactId>logging-libs</artifactId>
<version>1.0.1</version>
</dependency>
this library contains file with custom configuration: log4j2-include.xml
.
How can i write the path to my configuration file in log4j2.xml
using log4j2 include feature.
I tried this but it doesn't work:
<?xml version="1.0" encoding="UTF-8"?>
<configuration status="WARN" xmlns:xi="http://www.w3.org/2001/XInclude">
<Properties>
<Property name="logger.app" value="${spring:appName:-UNDEFINED}"/>
<Property name="logger.appVersion" value="${spring:appVersion:-UNDEFINED}"/>
</Properties>
<xi:include href="log4j2-include.xml"/>
</configuration>
ERROR:
[Warning] log4j2.xml:7:44: Include operation failed, reverting to fallback. Resource error reading file as XML (href='log4j2-include.xml'). Reason: C:\Users\...\IdeaProjects\my-logging\target\classes\log4j2-include.xml (�� ������� ����� ��������� ����)
[Fatal Error] log4j2.xml:7:44: An include with href 'log4j2-include.xml'failed, and no fallback element was found.
ERROR StatusLogger Error parsing C:\Users\...\IdeaProjects\my-logging\target\classes\log4j2.xml
org.xml.sax.SAXParseException; systemId: file:///C:/Users/.../IdeaProjects/my-logging/target/classes/log4j2.xml; lineNumber: 7; columnNumber: 44; An include with href 'log4j2-include.xml'failed, and no fallback element was found.
at java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:261)
at java.xml/com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:339)
at org.apache.logging.log4j.core.config.xml.XmlConfiguration.<init>(XmlConfiguration.java:94)
at org.apache.logging.log4j.core.config.xml.XmlConfigurationFactory.getConfiguration(XmlConfigurationFactory.java:46)
at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:533)
at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:457)
at org.apache.logging.log4j.core.config.ConfigurationFactory.getConfiguration(ConfigurationFactory.java:318)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:690)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:711)
at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:253)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:155)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:47)
at org.apache.logging.log4j.LogManager.getContext(LogManager.java:196)
at org.apache.commons.logging.LogAdapter$Log4jLog.<clinit>(LogAdapter.java:155)
at org.apache.commons.logging.LogAdapter$Log4jAdapter.createLog(LogAdapter.java:122)
at org.apache.commons.logging.LogAdapter.createLog(LogAdapter.java:89)
at org.apache.commons.logging.LogFactoryService.getInstance(LogFactoryService.java:46)
at org.apache.commons.logging.LogFactoryService.getInstance(LogFactoryService.java:41)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:655)
at org.springframework.boot.SpringApplication.<clinit>(SpringApplication.java:203)
at my.pack.DemoLoggingApplication.main(DemoLoggingApplication.java:10)
ERROR StatusLogger No logging configuration