You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "Günther Falk (JIRA)" <ji...@apache.org> on 2015/06/24 10:13:44 UTC

[jira] [Comment Edited] (LOG4J2-369) How to include the log4j2 lib jar into a jar with my application class and run it ?

    [ https://issues.apache.org/jira/browse/LOG4J2-369?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14599052#comment-14599052 ] 

Günther Falk edited comment on LOG4J2-369 at 6/24/15 8:13 AM:
--------------------------------------------------------------

Hi,

I was able to regenerate the Log4j2Plugins.dat file:
I unzipped the sources of log4j-api, log4j-core and log4j-slf4j-impl into my maven project source directory.
Afterwards I added the following dependencies:
{code}
<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-api</artifactId>
			<version>1.7.12</version>
		</dependency>
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-ext</artifactId>
			<version>1.7.12</version>
		</dependency>
		<dependency>
			<groupId>org.osgi</groupId>
			<artifactId>org.osgi.core</artifactId>
			<version>4.3.1</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>javax</groupId>
			<artifactId>javaee-api</artifactId>
			<version>7.0</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>com.fasterxml.jackson.core</groupId>
			<artifactId>jackson-core</artifactId>
			<version>2.5.3</version>
			<optional>true</optional>
		</dependency>
		<dependency>
			<groupId>com.fasterxml.jackson.core</groupId>
			<artifactId>jackson-databind</artifactId>
			<version>2.5.3</version>
			<optional>true</optional>
		</dependency>
		<dependency>
			<groupId>com.fasterxml.jackson.dataformat</groupId>
			<artifactId>jackson-dataformat-yaml</artifactId>
			<version>2.5.3</version>
			<optional>true</optional>
		</dependency>
		<dependency>
			<groupId>com.fasterxml.jackson.dataformat</groupId>
			<artifactId>jackson-dataformat-xml</artifactId>
			<version>2.5.3</version>
			<optional>true</optional>
		</dependency>
		<dependency>
			<groupId>com.fasterxml.jackson.module</groupId>
			<artifactId>jackson-module-jaxb-annotations</artifactId>
			<version>2.5.3</version>
			<optional>true</optional>
		</dependency>
{code}
And as described on the log4j2 page the following annotation processor:
{code}
<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-compiler-plugin</artifactId>
	<executions>
		<execution>
			<id>log4j-plugin-processor</id>
			<goals>
				<goal>compile</goal>
			</goals>
			<phase>process-classes</phase>
			<configuration>
				<proc>only</proc>
				<annotationProcessors>
					<annotationProcessor>org.apache.logging.log4j.core.config.plugins.processor.PluginProcessor</annotationProcessor>
				</annotationProcessors>
			</configuration>
		</execution>
	</executions>
</plugin>
{code}
With that I got a Log4j2Plugins.dat file including my extension and the default ones.

The class files published on the maven central repository do not include the Annotations when being compiled. Hence the annotation processor is unable to detect them when only unzipping the compiled classes.

Kind Regards

Günther


was (Author: falkgu):
Hi,

I was able to regenerate the Log4j2Plugins.dat file:
I unzipped the sources of log4j-api, log4j-core and log4j-slf4j-impl into my maven project source directory.
Afterwards I added the following dependencies:
{code}
<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-api</artifactId>
			<version>1.7.12</version>
		</dependency>
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-ext</artifactId>
			<version>1.7.12</version>
		</dependency>
		<dependency>
			<groupId>org.osgi</groupId>
			<artifactId>org.osgi.core</artifactId>
			<version>4.3.1</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>javax</groupId>
			<artifactId>javaee-api</artifactId>
			<version>7.0</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>com.fasterxml.jackson.core</groupId>
			<artifactId>jackson-core</artifactId>
			<version>2.5.3</version>
			<optional>true</optional>
		</dependency>
		<dependency>
			<groupId>com.fasterxml.jackson.core</groupId>
			<artifactId>jackson-databind</artifactId>
			<version>2.5.3</version>
			<optional>true</optional>
		</dependency>
		<dependency>
			<groupId>com.fasterxml.jackson.dataformat</groupId>
			<artifactId>jackson-dataformat-yaml</artifactId>
			<version>2.5.3</version>
			<optional>true</optional>
		</dependency>
		<dependency>
			<groupId>com.fasterxml.jackson.dataformat</groupId>
			<artifactId>jackson-dataformat-xml</artifactId>
			<version>2.5.3</version>
			<optional>true</optional>
		</dependency>
		<dependency>
			<groupId>com.fasterxml.jackson.module</groupId>
			<artifactId>jackson-module-jaxb-annotations</artifactId>
			<version>2.5.3</version>
			<optional>true</optional>
		</dependency>
{code}
And as described on the log4j2 page the following annotation processor:
{code}
<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-compiler-plugin</artifactId>
	<executions>
		<execution>
			<id>log4j-plugin-processor</id>
			<goals>
				<goal>compile</goal>
			</goals>
			<phase>process-classes</phase>
			<configuration>
				<proc>only</proc>
				<annotationProcessors>
					<annotationProcessor>org.apache.logging.log4j.core.config.plugins.processor.PluginProcessor</annotationProcessor>
				</annotationProcessors>
			</configuration>
		</execution>
	</executions>
</plugin>
{code}
With that I got a Log4j2Plugins.dat fiel including my extension and the default ones.

Kind Regards

Günther

> How to include the log4j2 lib jar into a jar with my application class and run it ?
> -----------------------------------------------------------------------------------
>
>                 Key: LOG4J2-369
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-369
>             Project: Log4j 2
>          Issue Type: Bug
>            Reporter: wei wang
>              Labels: mentor
>   Original Estimate: 0.2h
>  Remaining Estimate: 0.2h
>
> I used ant to build a app.jar which has log4j2.xml in the jar, however when I run the jar, it will miss the log4j2-core***.jar and log4j2-api***.jar as the lib. But I need to distribute the lib together with my app.jar as one jar file and run the app.jar(with the exlib in the jar), please tell me how to do that?
> I have tried simply pack the log4j2***.jar into the app.jar, but never print out any log, I think somehow must set the path inside jar to point the log4j2.properties in the log4j-***.jar file.
> Thanks!



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org