Skip to content

Commit 68ead62

Browse files
authored
Merge pull request #17964 from iterate-ch/bugfix/log4j-root-logger
Do not set hard coded log level to ERROR but honor root logger level …
2 parents f5b81f0 + d51117c commit 68ead62

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

core/src/main/java/ch/cyberduck/core/preferences/Preferences.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,10 +327,18 @@ public void setLogging(final String level) {
327327
this.configureLogging(level);
328328
}
329329

330+
/**
331+
* Reset logging configuration to default level from configuration
332+
*/
333+
public void resetLogging() {
334+
this.deleteProperty("logging");
335+
this.configureLogging(null);
336+
}
337+
330338
/**
331339
* Reconfigure logging configuration
332340
*
333-
* @param level Log level
341+
* @param level Log level or null to use default level from configuration
334342
*/
335343
protected void configureLogging(final String level) {
336344
// Call only once during initialization time of your application
@@ -346,10 +354,13 @@ protected void configureLogging(final String level) {
346354
}
347355
catch(IOException e) {
348356
log.error("Failure configuring log4j", e);
357+
Configurator.setRootLevel(Level.ERROR);
349358
}
350359
}
351-
// Allow to override default logging level
352-
Configurator.setRootLevel(Level.toLevel(level, Level.ERROR));
360+
if(StringUtils.isNotEmpty(level)) {
361+
// Allow to override default logging level
362+
Configurator.setRootLevel(Level.toLevel(level, Level.ERROR));
363+
}
353364
// Map logging level to pass through bridge
354365
final ImmutableMap<Level, java.util.logging.Level> map = new ImmutableMap.Builder<Level, java.util.logging.Level>()
355366
.put(Level.ALL, java.util.logging.Level.ALL)
@@ -369,7 +380,7 @@ protected void configureLogging(final String level) {
369380
java.util.logging.Logger.getLogger(loggerConfig.getName()).setLevel(map.get(loggerConfig.getLevel()));
370381
}
371382
}
372-
this.configureAppenders(level);
383+
this.configureAppenders(LogManager.getRootLogger().getLevel().name());
373384
}
374385

375386
private InputStream getLogConfiguration() {

osx/src/main/java/ch/cyberduck/ui/cocoa/controller/PreferencesController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2470,7 +2470,7 @@ public void logCheckboxClicked(final NSButton sender) {
24702470
preferences.setLogging(Level.DEBUG.toString());
24712471
break;
24722472
default:
2473-
preferences.setLogging(Level.ERROR.toString());
2473+
preferences.resetLogging();
24742474
break;
24752475
}
24762476
}

windows/src/main/csharp/ch/cyberduck/ui/controller/PreferencesController.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,14 @@ private void View_ShowDebugLogEvent()
193193

194194
private void View_DebugLogChangedEvent()
195195
{
196-
PreferencesFactory.get().setLogging(View.DebugLog ? Level.DEBUG.toString() : Level.ERROR.toString());
196+
if (View.DebugLog)
197+
{
198+
PreferencesFactory.get().setLogging(Level.DEBUG.name());
199+
}
200+
else
201+
{
202+
PreferencesFactory.get().resetLogging();
203+
}
197204
}
198205

199206
private void View_SegmentedDownloadsChangedEvent()

0 commit comments

Comments
 (0)