Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Centralize log4j2.xml #522

Closed
nynymike opened this issue Apr 7, 2017 · 9 comments
Closed

Centralize log4j2.xml #522

nynymike opened this issue Apr 7, 2017 · 9 comments
Assignees
Milestone

Comments

@nynymike
Copy link
Contributor

nynymike commented Apr 7, 2017

log4j2.xml needs to be moved outside of the war file. Not only is the current location bad...
but also, it is overwritten from the original war file on restart of jetty. Finally, the export script also needs to make sure that the log4j2.xml is backed up and restored.

I'm putting this as a 3.1 issue, but a workaround also needs to be documented for version 3, or we will not be able to handle cluster logs.

@nynymike nynymike added the bug label Apr 7, 2017
@nynymike nynymike added this to the CE 3.1.0 milestone Apr 7, 2017
@yurem
Copy link
Contributor

yurem commented Apr 10, 2017

In oxAuth/oxTrust log files all log folders are relative to 'catalina.base' variable. We set it in /etс/defaults/oxauth

As result in 3.0.1 it's easy to change location of application logs files via /etс/defaults/oxauth|oxtrust.

Also we can add programmatic approach too. In method AppInitializer.updateLoggingSeverity we need to add:
if (need_to_change_logs_location) {
System.setProperty("catalina.base", "/path/to/log/folder");
LoggerContext loggerContext = LoggerContext.getContext(false);
loggerContext.reconfigure();
}

I offer to add new system variable 'gluu.base.log' (or any better name) then continue to use tomcat specific variable 'catalina.base'

@nynymike
Copy link
Contributor Author

yes, please proceed.

@willow9886
Copy link
Contributor

It would be nice if we had a work around in 3.0.2 and a final solution in 3.1.0.

@worm333
Copy link
Contributor

worm333 commented May 3, 2017

@nynymike I'm not quite understand why the current location of log4j.xml is bad and what original.war file is overwriting it. Could you please elaborate more on this issue?

And I'm afraid I didn't get what kind of export script are you talking about.

@yurem
Copy link
Contributor

yurem commented May 3, 2017

In our log4j2.xml all folders are relative to ${sys:catalina.base} We can use this. In method which apply log level we can try to set this system variable value to change log files location.
Additionally I offer to rename "catalina.base" to "log.base".

@shekhar16
Copy link
Collaborator

shekhar16 commented May 3, 2017

to move log4j.xml file outside war file, we need to add in deployment descriptor.
<context-param> <param-name>log4jConfigLocation</param-name> <param-value>file://${MY_ENV_VAR}log4j.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class> </listener>

@yurem
Copy link
Contributor

yurem commented May 3, 2017

@mike, are we really need to move log4j2.xml outside of war or we just need to allow to move log files to other folder? log4j2.xml is part of oxAuth.war which is mandatory to proper server start.

@worm333
Copy link
Contributor

worm333 commented May 5, 2017

@yurem, @nynymike please correct me if I'm wrong. As I understand the goal of this issue is to provide the possibility to admins to change the location of log files.

So basically we need to add into /identity/logviewer/configure page new field e.g.: Log base where admins could change the location of log files.
Also we need to update identity template in community-edition-setup in order to rename system variable catalina.base to log.base ( and also rename all usages of catalina.base in oxTrust).

@worm333
Copy link
Contributor

worm333 commented Jun 5, 2017

I've added new field External log4j location in /identity/logviewer/configure form. If field is empty or path to external log4j is incorrect (file does not exist), then log4j2 will read the default logger config from .war (otherwise logger will be configured from external config)

@worm333 worm333 closed this as completed Jun 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants