use of liquibase.logging.LogService in project liquibase by liquibase.
the class LiquibaseCommandLine method configureLogging.
private void configureLogging(Level logLevel, File logFile) throws IOException {
configuredLogLevel = logLevel;
System.setProperty("java.util.logging.SimpleFormatter.format", "[%1$tF %1$tT] %4$s [%2$s] %5$s%6$s%n");
java.util.logging.Logger liquibaseLogger = java.util.logging.Logger.getLogger("liquibase");
final JavaLogService logService = (JavaLogService) Scope.getCurrentScope().get(Scope.Attr.logService, LogService.class);
logService.setParent(liquibaseLogger);
java.util.logging.Logger rootLogger = java.util.logging.Logger.getLogger("");
Level cliLogLevel = logLevel;
if (logFile != null) {
if (fileHandler == null) {
fileHandler = new FileHandler(logFile.getAbsolutePath(), true);
fileHandler.setFormatter(new SimpleFormatter());
rootLogger.addHandler(fileHandler);
}
fileHandler.setLevel(logLevel);
if (logLevel == Level.OFF) {
fileHandler.setLevel(Level.FINE);
}
cliLogLevel = Level.OFF;
}
rootLogger.setLevel(logLevel);
liquibaseLogger.setLevel(logLevel);
for (Handler handler : rootLogger.getHandlers()) {
if (handler instanceof ConsoleHandler) {
handler.setLevel(cliLogLevel);
}
handler.setFilter(new SecureLogFilter(logService.getFilter()));
}
}
use of liquibase.logging.LogService in project liquibase by liquibase.
the class Scope method getCurrentScope.
public static Scope getCurrentScope() {
if (scopeManager == null) {
scopeManager = new SingletonScopeManager();
}
if (scopeManager.getCurrentScope() == null) {
Scope rootScope = new Scope();
scopeManager.setCurrentScope(rootScope);
rootScope.values.put(Attr.logService.name(), new JavaLogService());
rootScope.values.put(Attr.resourceAccessor.name(), new ClassLoaderResourceAccessor());
rootScope.values.put(Attr.serviceLocator.name(), new StandardServiceLocator());
rootScope.values.put(Attr.ui.name(), new ConsoleUIService());
rootScope.getSingleton(LiquibaseConfiguration.class).init(rootScope);
LogService overrideLogService = rootScope.getSingleton(LogServiceFactory.class).getDefaultLogService();
if (overrideLogService == null) {
throw new UnexpectedLiquibaseException("Cannot find default log service");
}
rootScope.values.put(Attr.logService.name(), overrideLogService);
// check for higher-priority serviceLocator
ServiceLocator serviceLocator = rootScope.getServiceLocator();
for (ServiceLocator possibleLocator : serviceLocator.findInstances(ServiceLocator.class)) {
if (possibleLocator.getPriority() > serviceLocator.getPriority()) {
serviceLocator = possibleLocator;
}
}
rootScope.values.put(Attr.serviceLocator.name(), serviceLocator);
rootScope.values.put(Attr.osgiPlatform.name(), Activator.OSGIContainerChecker.isOsgiPlatform());
}
return scopeManager.getCurrentScope();
}
Aggregations