Martin Peřina has posted comments on this change.

Change subject: core: Add common methods for runtime log4j setup
......................................................................


Patch Set 2:

(3 comments)

http://gerrit.ovirt.org/#/c/26588/2/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/log/Log4jUtils.java
File 
backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/log/Log4jUtils.java:

Line 23:      *            path or URL to external log4j.xml file
Line 24:      * @param defaultUrl
Line 25:      *            URL with default log4j.xml
Line 26:      */
Line 27:     public static void setupLogging(String log4jConfig, URL 
defaultUrl) {
> why one is string and the other URL?
String is the value set in --log-file, I just pass the responsibility to log4j 
to parse it.

For default config I pass URL, since the default log4j.xml is in jar, so this 
URL should be created by class, that is contained in the same jar as log4j.xml.
Line 28:         try {
Line 29:             LogManager.resetConfiguration();
Line 30:             if (log4jConfig == null) {
Line 31:                 DOMConfigurator.configure(defaultUrl);


Line 46:      * @param levelName
Line 47:      *            log level to use
Line 48:      */
Line 49:     public static void addFileAppender(String fileName, String 
levelName) {
Line 50:         if (fileName != null) {
> why anyone will want to call this function if fileName is null?
I don't validate command line args for --log-file and --log-level, validation 
is part of this function.
Line 51:             Level level = Level.INFO;
Line 52:             if (levelName != null) {
Line 53:                 level = Level.toLevel(levelName, null);
Line 54:                 if (level == null) {


Line 59:             FileAppender fa = null;
Line 60:             try {
Line 61:                 fa = new FileAppender(new PatternLayout("%d %-5p [%c] 
%m%n"), fileName, true);
Line 62:                 fa.setThreshold(level);
Line 63:             } catch (SecurityException | IOException ex) {
> so now, please explain why we should have this try/catch block specific for
To be able to report user friendly error instead of stacktrace and this call is 
the only part where some exceptions can be thrown.
Line 64:                 throw new IllegalArgumentException(
Line 65:                         String.format("Error accessing log file '%s': 
'%s'", fileName, ex.getMessage()),
Line 66:                         ex);
Line 67:             }


-- 
To view, visit http://gerrit.ovirt.org/26588
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ic00ea0af643e8c978fd67eb8c56e2329d43e776d
Gerrit-PatchSet: 2
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Martin Peřina <mper...@redhat.com>
Gerrit-Reviewer: Alon Bar-Lev <alo...@redhat.com>
Gerrit-Reviewer: Eli Mesika <emes...@redhat.com>
Gerrit-Reviewer: Martin Peřina <mper...@redhat.com>
Gerrit-Reviewer: Oved Ourfali <oourf...@redhat.com>
Gerrit-Reviewer: automat...@ovirt.org
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to