You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use AppDirs to set my log file directory, but AppDirs using a logger itself makes this very difficult as it loads my logger before I am able to set my logging directory system property to a path obtained by AppDirs.
If you want to keep logging in AppDirs (Which at this time is only used in ShellFolderResolver and AppDirsFactory), how about some method of obtaining an AppDirsFactory with a disabled logger?
public class AppDirsFactory {
private static Logger logger;
private AppDirsFactory() {
super();
}
public static AppDirs getInstanceWithoutLogger() {
logger = NOPLogger.NOP_LOGGER;
return createInstance(false);
}
public static AppDirs getInstance() {
logger = LoggerFactory.getLogger(AppDirsFactory.class);
return createInstance(true);
}
private static AppDirs createInstance(final boolean logging) {
String os = System.getProperty("os.name").toLowerCase();
if (os.startsWith("mac os x")) {
// ...
} else if (os.startsWith("windows")) {
logger.debug("os.name {} is resolved to Windows", os);
// do the same in ShellFolderResolver
WindowsFolderResolver folderResolver = new ShellFolderResolver(logging);
return new WindowsAppDirs(folderResolver);
} else {
// ...
}
}
}
I realize this isn't super pretty, but I feel like something like this is much needed. Not creating a logger while trying to find out which directory to log to would improve this already excellent little library, and I feel like this must be a pretty common use case.
The text was updated successfully, but these errors were encountered:
marvk
added a commit
to marvk/vatprism
that referenced
this issue
Jan 25, 2021
This very much relates to #4
I'm trying to use AppDirs to set my log file directory, but AppDirs using a logger itself makes this very difficult as it loads my logger before I am able to set my logging directory system property to a path obtained by AppDirs.
If you want to keep logging in AppDirs (Which at this time is only used in
ShellFolderResolver
andAppDirsFactory
), how about some method of obtaining anAppDirsFactory
with a disabled logger?I realize this isn't super pretty, but I feel like something like this is much needed. Not creating a logger while trying to find out which directory to log to would improve this already excellent little library, and I feel like this must be a pretty common use case.
The text was updated successfully, but these errors were encountered: