@Override protected Component createComponent() { Component component = super.createComponent(); // a bit more configuration by initParams LogService log = component.getLogService(); // allow access to the LogService in the application via the context component.getContext().getAttributes().put(LogService.class.getName(), log); // modify the logger name String loggerName = getInitParameter(LOGGER_NAME_ATTRIBUTE, LOGGER_NAME_ATTRIBUTE_DEFAULT_VALUE); log.setLoggerName(loggerName); // modify the logger pattern // note: overridden to be smaller than the restlet default value log.setResponseLogFormat(getInitParameter(LOGGER_FORMAT_ATTRIBUTE, LOGGER_FORMAT_ATTRIBUTE_DEFAULT_VALUE)); return component; } }
/// <summary> /// The main entry point for the application. /// </summary> static void Main() { ServiceBase[] ServicesToRun; LogService logService = new LogService(); logService.CanHandleSessionChangeEvent = true; ServicesToRun = new ServiceBase[] { logService }; ServiceBase.Run(ServicesToRun); }
/** * Sets the URI reference of the log properties. * * @param logPropertiesUri * The URI reference of the log properties. */ public void setLogPropertiesRef(String logPropertiesUri) { setLogPropertiesRef(new Reference(logPropertiesUri)); }
/** * Starts the log service by attempting to read the log properties if the * {@link #getLogPropertiesRef()} returns a non null URI reference. */ @Override public synchronized void start() throws Exception { super.start(); this.responseLogTemplate = (getResponseLogFormat() == null) ? null : new Template(getResponseLogFormat()); if (getLogPropertiesRef() != null) { Representation logProperties = new ClientResource(getContext(), getLogPropertiesRef()).get(); if (logProperties != null) { java.util.logging.LogManager.getLogManager().readConfiguration( logProperties.getStream()); } } } }
.setResponseLogFormat(item.getNodeValue()); getComponent().getLogService().setLoggerName( item.getNodeValue()); getComponent().getLogService().setEnabled( getBoolean(item, true)); getComponent().getLogService().setIdentityCheck( getBoolean(item, true));
getLogService().setLoggerName("MailServer.AccessLog"); getLogService() .setLogPropertiesRef( "clap://system/org/restlet/example/book/restlet/ch04/sec3/server/log.properties");
getLogService().setLogFormat(item.getNodeValue()); getLogService().setLoggerName(item.getNodeValue()); getLogService().setEnabled(getBoolean(item, true)); getLogService().setIdentityCheck( getBoolean(item, true));
/** * Constructor. */ public Component() { super(); this.hosts = new CopyOnWriteArrayList<VirtualHost>(); this.clients = new ClientList(null); this.servers = new ServerList(null, this); this.realms = new CopyOnWriteArrayList<Realm>(); this.services = new ServiceList(getContext()); if (Engine.getInstance() != null) { // To be done before setting the helper... this.services.add(new org.restlet.service.TaskService()); this.helper = new ComponentHelper(this); Context childContext = getContext().createChildContext(); this.defaultHost = new VirtualHost(childContext); this.internalRouter = new InternalRouter(childContext); this.services.add(new LogService()); getLogService().setContext(childContext); this.services.add(new StatusService()); getStatusService().setContext(childContext); this.clients.setContext(childContext); this.servers.setContext(childContext); } }
getLogService().setLoggerName("MailServer.AccessLog"); getLogService() .setLogPropertiesRef( "clap://system/org/restlet/example/book/restlet/ch03/sec3/server/log.properties");
getLogService().setLoggerName("MailServer.AccessLog"); getLogService() .setLogPropertiesRef( "clap://system/org/restlet/example/book/restlet/ch05/sec3/server/log.properties");
this.logService = new LogService(true); this.statusService = new StatusService(true); this.clients.setContext(getContext());