/** * Start this component and implement the requirements * of {@link org.apache.catalina.util.LifecycleBase#startInternal()}. * * @exception LifecycleException if this component detects a fatal error * that prevents this component from being used */ @Override protected synchronized void startInternal() throws LifecycleException { // Initialize the Date formatters String format = getFileDateFormat(); if (format == null || format.length() == 0) { format = "yyyy-MM-dd"; setFileDateFormat(format); } fileDateFormatter = new SimpleDateFormat(format, Locale.US); fileDateFormatter.setTimeZone(timezone); dateStamp = fileDateFormatter.format(new Date(System.currentTimeMillis())); open(); setState(LifecycleState.STARTING); }
/** * Start this component and implement the requirements * of {@link org.apache.catalina.util.LifecycleBase#startInternal()}. * * @exception LifecycleException if this component detects a fatal error * that prevents this component from being used */ @Override protected synchronized void startInternal() throws LifecycleException { // Initialize the timeZone, Date formatters, and currentDate TimeZone tz = TimeZone.getDefault(); timezone = tz; timeZoneNoDST = calculateTimeZoneOffset(tz.getRawOffset()); int offset = tz.getDSTSavings(); timeZoneDST = calculateTimeZoneOffset(tz.getRawOffset() + offset); String format = getFileDateFormat(); if (format == null || format.length() == 0) { format = "yyyy-MM-dd"; setFileDateFormat(format); } fileDateFormatter = new SimpleDateFormat(format); fileDateFormatter.setTimeZone(tz); dateStamp = fileDateFormatter.format(currentDateStruct.get().currentDate); open(); setState(LifecycleState.STARTING); }
/** * Start this component and implement the requirements * of {@link org.apache.catalina.util.LifecycleBase#startInternal()}. * * @exception LifecycleException if this component detects a fatal error * that prevents this component from being used */ @Override protected synchronized void startInternal() throws LifecycleException { // Initialize the timeZone, Date formatters, and currentDate TimeZone tz = TimeZone.getDefault(); timezone = tz; timeZoneNoDST = calculateTimeZoneOffset(tz.getRawOffset()); int offset = tz.getDSTSavings(); timeZoneDST = calculateTimeZoneOffset(tz.getRawOffset() + offset); String format = getFileDateFormat(); if (format == null || format.length() == 0) { format = "yyyy-MM-dd"; setFileDateFormat(format); } fileDateFormatter = new SimpleDateFormat(format); fileDateFormatter.setTimeZone(tz); dateStamp = fileDateFormatter.format(currentDateStruct.get().currentDate); open(); setState(LifecycleState.STARTING); }
/** * Start this component and implement the requirements * of {@link org.apache.catalina.util.LifecycleBase#startInternal()}. * * @exception LifecycleException if this component detects a fatal error * that prevents this component from being used */ @Override protected synchronized void startInternal() throws LifecycleException { // Initialize the timeZone, Date formatters, and currentDate TimeZone tz = TimeZone.getDefault(); timezone = tz; timeZoneNoDST = calculateTimeZoneOffset(tz.getRawOffset()); int offset = tz.getDSTSavings(); timeZoneDST = calculateTimeZoneOffset(tz.getRawOffset() + offset); String format = getFileDateFormat(); if (format == null || format.length() == 0) { format = "yyyy-MM-dd"; setFileDateFormat(format); } fileDateFormatter = new SimpleDateFormat(format); fileDateFormatter.setTimeZone(tz); dateStamp = fileDateFormatter.format(currentDateStruct.get().currentDate); open(); setState(LifecycleState.STARTING); }
protected void setupAccessLogIfNeeds(Context ctx) { if (accessLogOption != null && ctx instanceof StandardContext) { // also check context type just in case final StandardContext stdctx = (StandardContext) ctx; final AccessLogValve valve = new AccessLogValve(); accessLogOption.getLogDir().ifPresent(dir -> valve.setDirectory(dir)); accessLogOption.getFilePrefix().ifPresent(prefix -> valve.setPrefix(prefix)); accessLogOption.getFileSuffix().ifPresent(suffix -> valve.setSuffix(suffix)); accessLogOption.getFileDateFormat().ifPresent(format -> valve.setFileDateFormat(format)); valve.setEncoding(accessLogOption.getFileEncoding().orElse("UTF-8")); valve.setPattern(accessLogOption.getFormatPattern().orElse("common")); accessLogOption.getConditionIf().ifPresent(cond -> valve.setConditionIf(cond)); accessLogOption.getConditionUnless().ifPresent(cond -> valve.setConditionUnless(cond)); stdctx.addValve(valve); } }
private void configEngine(Engine engine, TomcatConf tomcatConf) { engine.setBackgroundProcessorDelay(tomcatConf.getBackgroundProcessorDelay()); if (tomcatConf.isAccessLogEnabled()) { AccessLogValve value = new AccessLogValve(); value.setBuffered(tomcatConf.isAccessLogBuffered()); value.setFileDateFormat(tomcatConf.getAccessLogFileFormat()); value.setRequestAttributesEnabled(tomcatConf.isAccessLogRequestAttributesEnabled()); value.setPattern(tomcatConf.getAccessLogPattern()); engine.getPipeline().addValve(value); } }