mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
change log level at runtime
This commit is contained in:
@@ -72,10 +72,12 @@ public class StartupBean {
|
|||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
private void init() {
|
private void init() {
|
||||||
|
|
||||||
startupTime = Calendar.getInstance().getTimeInMillis();
|
startupTime = Calendar.getInstance().getTimeInMillis();
|
||||||
if (userDAO.getCount() == 0) {
|
if (userDAO.getCount() == 0) {
|
||||||
initialData();
|
initialData();
|
||||||
}
|
}
|
||||||
|
applicationSettingsService.applyLogLevel();
|
||||||
|
|
||||||
initSupportedLanguages();
|
initSupportedLanguages();
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import javax.xml.bind.annotation.XmlAccessType;
|
|||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
import org.apache.log4j.Level;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "APPLICATIONSETTINGS")
|
@Table(name = "APPLICATIONSETTINGS")
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
@@ -29,6 +31,7 @@ public class ApplicationSettings extends AbstractModel {
|
|||||||
private boolean heavyLoad;
|
private boolean heavyLoad;
|
||||||
private boolean pubsubhubbub;
|
private boolean pubsubhubbub;
|
||||||
private boolean feedbackButton = true;
|
private boolean feedbackButton = true;
|
||||||
|
private String logLevel = Level.INFO.toString();
|
||||||
|
|
||||||
@Column(length = 255)
|
@Column(length = 255)
|
||||||
private String announcement;
|
private String announcement;
|
||||||
@@ -162,4 +165,12 @@ public class ApplicationSettings extends AbstractModel {
|
|||||||
this.databaseUpdateThreads = databaseUpdateThreads;
|
this.databaseUpdateThreads = databaseUpdateThreads;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getLogLevel() {
|
||||||
|
return logLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLogLevel(String logLevel) {
|
||||||
|
this.logLevel = logLevel;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,14 @@
|
|||||||
package com.commafeed.backend.services;
|
package com.commafeed.backend.services;
|
||||||
|
|
||||||
|
import java.util.Enumeration;
|
||||||
|
|
||||||
import javax.ejb.Singleton;
|
import javax.ejb.Singleton;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import org.apache.log4j.Level;
|
||||||
|
import org.apache.log4j.LogManager;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.commafeed.backend.dao.ApplicationSettingsDAO;
|
import com.commafeed.backend.dao.ApplicationSettingsDAO;
|
||||||
import com.commafeed.backend.model.ApplicationSettings;
|
import com.commafeed.backend.model.ApplicationSettings;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
@@ -18,6 +24,7 @@ public class ApplicationSettingsService {
|
|||||||
public void save(ApplicationSettings settings) {
|
public void save(ApplicationSettings settings) {
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
applicationSettingsDAO.saveOrUpdate(settings);
|
applicationSettingsDAO.saveOrUpdate(settings);
|
||||||
|
applyLogLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApplicationSettings get() {
|
public ApplicationSettings get() {
|
||||||
@@ -28,4 +35,17 @@ public class ApplicationSettingsService {
|
|||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public void applyLogLevel() {
|
||||||
|
String logLevel = get().getLogLevel();
|
||||||
|
Level level = Level.toLevel(logLevel);
|
||||||
|
|
||||||
|
Enumeration<Logger> loggers = LogManager.getCurrentLoggers();
|
||||||
|
while (loggers.hasMoreElements()) {
|
||||||
|
Logger logger = loggers.nextElement();
|
||||||
|
if (logger.getName().startsWith("com.commafeed")) {
|
||||||
|
logger.setLevel(level);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -137,6 +137,13 @@
|
|||||||
<input type="checkbox" name="pubsubhubbub" ng-model="settings.pubsubhubbub" />
|
<input type="checkbox" name="pubsubhubbub" ng-model="settings.pubsubhubbub" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label" for="logLevel">Logging level</label>
|
||||||
|
<div class="controls">
|
||||||
|
<select name="logLevel" ng-model="settings.logLevel" ng-options="level for level in ['DEBUG', 'INFO', 'WARN', 'ERROR']">
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
|
|||||||
Reference in New Issue
Block a user