X Tutup
Skip to content

log4j.xml relocated and excluded from JAR#287

Merged
iluwatar merged 2 commits intoiluwatar:masterfrom
LuigiCortese:master
Nov 14, 2015
Merged

log4j.xml relocated and excluded from JAR#287
iluwatar merged 2 commits intoiluwatar:masterfrom
LuigiCortese:master

Conversation

@LuigiCortese
Copy link
Copy Markdown
Contributor

log4j.xml relocated due to visibility issues and excluded from generated JAR. pom.xml formatted according to coding conventions

JAR. pom.xml formatted according to coding conventions
@iluwatar
Copy link
Copy Markdown
Owner

Hi @l-cortese Can you explain a bit how it works?

dao/pom.xml Outdated
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Twice the same?

@LuigiCortese
Copy link
Copy Markdown
Contributor Author

Ok, there was a typo in the comment at line 29 of pom.xml, it should be

log4j.xml file will be copied both in ${project.build.outputDirectory} and ${project.build.directory}.

${project.build.outputDirectory} is target/classes
${project.build.directory} is target

log4j.xml must be copied under target/classes for the project to run correctly in Eclipse (nothing new here). jar:jar plugin, by default, makes up a JAR archive by copying the tree structure under target/classes, so it would include log4j.xml too. To exclude it from the JAR, I configured the plugin in the pom and "moved" log4j.xml to same level dir target, so it can be used (and modified if needed) without affecting the JAR.

@LuigiCortese
Copy link
Copy Markdown
Contributor Author

Now... if I wanted to correct the comments, should I treat it like a totally new PR?

@LuigiCortese
Copy link
Copy Markdown
Contributor Author

ok, just pushed corrections to the master branch in my repo

@iluwatar
Copy link
Copy Markdown
Owner

Great, thanks for the explanation. So now that the config file is outside the jar it is possible to modify it and run the dao.jar with the altered configuration with some command?

@LuigiCortese
Copy link
Copy Markdown
Contributor Author

Exactly, you can run dao-1.8.0-SNAPSHOT.jar via commandline specifing some options:

java -Dlog4j.configuration=file:.\log4j.xml -cp .\dao-1.8.0-SNAPSHOT.jar com.iluwatar.dao.App

paying attention to include referenced libraries in the classpath

iluwatar added a commit that referenced this pull request Nov 14, 2015
log4j.xml relocated and excluded from JAR
@iluwatar iluwatar merged commit 033f8e7 into iluwatar:master Nov 14, 2015
@iluwatar
Copy link
Copy Markdown
Owner

Thank you. It works as you explained.

pratigya0 pushed a commit to pratigya0/java-design-patterns that referenced this pull request Aug 3, 2023
…atar#287)

* add description for AWS CloudFormation, AWS CDK

* adding cdk

* fixing typo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

X Tutup