-
Notifications
You must be signed in to change notification settings - Fork 140
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
Add support for subsystem logging.properties #4962
Open
edewata
wants to merge
1
commit into
dogtagpki:master
Choose a base branch
from
edewata:logging
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
import java.io.FileReader; | ||
import java.util.Map; | ||
import java.util.Properties; | ||
import java.util.logging.Logger; | ||
|
||
import org.apache.catalina.Realm; | ||
import org.apache.catalina.realm.RealmBase; | ||
|
@@ -60,6 +61,7 @@ public void start(String contextPath) throws Throwable { | |
|
||
logger.info("EST configuration directory: " + estConfDir); | ||
|
||
loadLoggingProperties(estConfDir + File.separator + "logging.properties"); | ||
initBackend(estConfDir + File.separator + "backend.conf"); | ||
initRequestAuthorizer(estConfDir + File.separator + "authorizer.conf"); | ||
initRealm(estConfDir + File.separator + "realm.conf"); | ||
|
@@ -87,6 +89,28 @@ public void stop() throws Throwable { | |
logger.info("EST engine stopped"); | ||
} | ||
|
||
public void loadLoggingProperties(String loggingProperties) throws Exception { | ||
|
||
File file = new File(loggingProperties); | ||
if (!file.exists()) return; | ||
|
||
logger.info("Loading " + loggingProperties); | ||
Properties properties = new Properties(); | ||
properties.load(new FileReader(file)); | ||
|
||
for (String key : properties.stringPropertyNames()) { | ||
String value = properties.getProperty(key); | ||
|
||
logger.info("- " + key + ": " + value); | ||
if (!key.endsWith(".level")) continue; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above |
||
String loggerName = key.substring(0, key.length() - 6); | ||
java.util.logging.Level level = java.util.logging.Level.parse(value); | ||
|
||
Logger.getLogger(loggerName).setLevel(level); | ||
} | ||
} | ||
|
||
private void initBackend(String filename) throws Throwable { | ||
File file = new File(filename); | ||
if (!file.exists()) { | ||
|
@@ -136,7 +160,7 @@ private void initRequestAuthorizer(String filename) throws Throwable { | |
private void initRealm(String filename) throws Throwable { | ||
RealmConfig realmConfig = null; | ||
File realmConfigFile = new File(filename); | ||
|
||
if (realmConfigFile.exists()) { | ||
logger.info("Loading EST realm config from " + realmConfigFile); | ||
Properties props = new Properties(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,8 +32,10 @@ | |
import java.util.LinkedHashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Properties; | ||
import java.util.StringTokenizer; | ||
import java.util.Timer; | ||
import java.util.logging.Logger; | ||
|
||
import javax.servlet.http.HttpServlet; | ||
|
||
|
@@ -122,8 +124,8 @@ public class CMSEngine { | |
|
||
private static final String SERVER_XML = "server.xml"; | ||
|
||
public String id; | ||
public String name; | ||
public String id; // subsystem ID (e.g. ca, kra) | ||
public String name; // subsystem name (e.g. CA, KRA) | ||
|
||
public String instanceDir; /* path to instance <server-root>/cert-<instance-name> */ | ||
private String instanceId; | ||
|
@@ -418,8 +420,31 @@ public synchronized PasswordStore getPasswordStore() throws EBaseException { | |
} | ||
|
||
public void initDebug() throws Exception { | ||
|
||
ConfigStore debugConfig = config.getSubStore(Debug.ID, ConfigStore.class); | ||
debug.init(debugConfig); | ||
|
||
String subsystemConfDir = CMS.getInstanceDir() + File.separator + "conf" + File.separator + id; | ||
String loggingProperties = subsystemConfDir + File.separator + "logging.properties"; | ||
|
||
File file = new File(loggingProperties); | ||
if (!file.exists()) return; | ||
|
||
logger.info("CMSEngine: Loading " + loggingProperties); | ||
Properties properties = new Properties(); | ||
properties.load(new FileReader(file)); | ||
|
||
for (String key : properties.stringPropertyNames()) { | ||
String value = properties.getProperty(key); | ||
|
||
logger.info("CMSEngine: - " + key + ": " + value); | ||
if (!key.endsWith(".level")) continue; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above |
||
String loggerName = key.substring(0, key.length() - 6); | ||
java.util.logging.Level level = java.util.logging.Level.parse(value); | ||
|
||
Logger.getLogger(loggerName).setLevel(level); | ||
} | ||
} | ||
|
||
public void initSubsystemListeners() throws Exception { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we call the file
logging.properties
I am expecting that the provided values should overwrite the existing to modify the logs. So I would try to update the full configurationThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I can try that. I wasn't sure whether the
LogManager
will override just the params specified in the customlogging.properties
or replace the entire logging config with the customlogging.properties
(meaning the handlers need to be redefined in the customlogging.properties
).