Skip to content
Snippets Groups Projects
Commit 175ce5a9 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

there is posibility to have log4j.properties in the external /etc/minerva/log4j.properties file

parent 6eb5553e
No related branches found
No related tags found
2 merge requests!630WIP: Resolve "The privileges of a new user are not saved in some cases",!424Resolve "log4j configuration should be exposed to the user"
Pipeline #6577 failed
package lcsb.mapviewer.bean.utils;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import javax.annotation.PostConstruct;
import javax.faces.bean.ApplicationScoped;
......@@ -10,6 +14,7 @@ import javax.faces.context.FacesContext;
import javax.servlet.ServletContext;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import lcsb.mapviewer.common.Configuration;
import lcsb.mapviewer.common.IProgressUpdater;
......@@ -69,6 +74,7 @@ public class StartupBean {
*/
@PostConstruct
public void init() {
loadCustomLog4jProperties();
logger.debug("Application startup script starts");
ServletContext servletContext = (ServletContext) FacesContext.getCurrentInstance().getExternalContext()
.getContext();
......@@ -81,6 +87,24 @@ public class StartupBean {
logger.debug("Application startup script ends");
}
private void loadCustomLog4jProperties() {
String filename = "/etc/minerva/log4j.properties";
File file = new File(filename);
if (file.exists()) {
try {
Properties props = new Properties();
InputStream configStream = new FileInputStream(file);
props.load(configStream);
configStream.close();
PropertyConfigurator.configure(props);
logger.info("log4j configuration loaded from: " + filename);
} catch (Exception e) {
logger.error("Problem with loading log4j configuration: " + filename);
}
}
}
private void setSessionLength() {
try {
String sessionLength = configurationService.getConfigurationValue(ConfigurationElementType.SESSION_LENGTH);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment