/** * Finds the log location in the "context" (system variable, env variable, servlet context) or * uses the provided base location otherwise */ public static String getLogFileLocation(String baseLocation) { return getLogFileLocation(baseLocation, null); }
/** * Returns the enum value corresponding to the name (using case insensitive comparison) or * Log4j if no match is found * * @param name */ public static GeoToolsLoggingRedirection findValue(String name) { for (GeoToolsLoggingRedirection value : values()) { if (value.name().equalsIgnoreCase(name)) return value; } return Log4J; } }
public void imprt(File dir) throws Exception { LegacyServicesReader reader = reader(dir); Map<String, Object> global = reader.global(); configFileName = (String) global.get("log4jConfigFile"); logFile = (String) global.get("logLocation"); suppressStdOutLogging = Converters.convert(global.get("suppressStdOutLogging"), Boolean.class); }
GeoToolsLoggingRedirection.findValue( GeoServerExtensions.getProperty( LoggingUtils.GT2_LOGGING_REDIRECTION, context)); getLogger().log(Level.SEVERE, "Could not configure log4j logging redirection", e); GeoServerExtensions.getProperty(LoggingUtils.RELINQUISH_LOG4J_CONTROL, context); if (Boolean.valueOf(relinquishLoggingControl)) { getLogger() .info( "RELINQUISH_LOG4J_CONTROL on, won't attempt to reconfigure LOG4J loggers"); LoggingInfo loginfo = getLogging(loader); if (loginfo != null) { final String location = LoggingUtils.getLogFileLocation( loginfo.getLocation(), event.getServletContext()); LoggingUtils.initLogging( loader, loginfo.getLevel(), !loginfo.isStdOutLogging(), location); } else { LegacyLoggingImporter loggingImporter = new LegacyLoggingImporter(); loggingImporter.imprt(baseDir); final String location = LoggingUtils.getLogFileLocation(loggingImporter.getLogFile(), null); LoggingUtils.initLogging( loader, loggingImporter.getConfigFileName(), loggingImporter.getSuppressStdOutLogging(),
@Test public void test() throws Exception { assertEquals("DEFAULT_LOGGING.properties", importer.getConfigFileName()); assertFalse(importer.getSuppressStdOutLogging()); assertEquals("logs/geoserver.log", importer.getLogFile()); } }
configureGeoServerLogging( resourceLoader, loggingConfigStream, suppressStdOutLogging, false, logFileName);
@Before public void setUp() throws Exception { gs = new GeoServerImpl(); importer = new LegacyLoggingImporter(); importer.imprt(URLs.urlToFile(getClass().getResource("services.xml")).getParentFile()); }
loggingLocation = LoggingUtils.getLogFileLocation(loggingLocation); LoggingUtils.initLogging( resourceLoader, loggingLevel,
@Test public void testInitLoggingLock() throws Exception { final File target = new File("./target"); FileUtils.deleteQuietly(new File(target, "logs")); GeoServerResourceLoader loader = new GeoServerResourceLoader(target); FileSystemResourceStore store = (FileSystemResourceStore) loader.getResourceStore(); store.setLockProvider(new MemoryLockProvider()); // make it copy the log files LoggingUtils.initLogging(loader, "DEFAULT_LOGGING.properties", false, null); // init once from default logging LoggingUtils.initLogging(loader, "DEFAULT_LOGGING.properties", false, null); // init twice, here it used to lock up LoggingUtils.initLogging(loader, "DEFAULT_LOGGING.properties", false, null); } }
System.setProperty(LoggingUtils.RELINQUISH_LOG4J_CONTROL, "false"); try { new LoggingStartupContextListener() .contextInitialized(new ServletContextEvent(context)); } finally { System.setProperty(LoggingUtils.RELINQUISH_LOG4J_CONTROL, "rel");
GeoServerResourceLoader loader = new GeoServerResourceLoader(testData.getDataDirectoryRoot()); LoggingUtils.configureGeoServerLogging( loader, getClass().getResourceAsStream(getLogConfiguration()), false, true, null);
GeoServerResourceLoader loader = new GeoServerResourceLoader(testData.getDataDirectoryRoot()); LoggingUtils.configureGeoServerLogging( loader, getClass().getResourceAsStream(getLogConfiguration()), false, true, null);
LoggingUtils.configureGeoServerLogging( loader, this.getClass().getResourceAsStream("/TEST_LOGGING.properties"),