All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.springframework.flex.core.CommonsLoggingTarget Maven / Gradle / Ivy

/*
 * Copyright 2002-2011 the original author or authors.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.flex.core;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import flex.messaging.config.ConfigMap;
import flex.messaging.log.AbstractTarget;
import flex.messaging.log.LogEvent;

/**
 * BlazeDS Logging target that logs messages using standard apache commons-logging. Configuration:
 * services-config.xml
 * 
 * 
 *  <logging>
 *      <target class="org.springframework.flex.core.CommonsLoggingTarget" level="All">
 *      	<properties>
 *      		<categoryPrefix>blazeds</categoryPrefix>
 *      	</properties>
 *      </target>
 *  </logging>
 * 
* * Underlying Logger Configuration (e.g. log4j.xml) * *
 * <log name="blazeds" additivity="false">
 *      <level value="DEBUG" />
 *  </log>
 * 
* * Following Categories are available in BlazeDS/LCDS: *
    *
  • Configuration
  • *
  • DataService.General
  • *
  • DataService.Hibernate
  • *
  • DataService.Transaction
  • *
  • Endpoint.*
  • *
  • Endpoint.AMF
  • *
  • Endpoint.HTTP
  • *
  • Endpoint.RTMP
  • *
  • Endpoint.Deserialization
  • *
  • Endpoint.General
  • *
  • Message.*
  • *
  • Message.Command.*
  • *
  • Message.Command.operation-name where operation-name is one of the following: subscribe, unsubscribe, poll, * poll_interval, client_sync, server_ping,client_ping, cluster_request, login, logout
  • *
  • Message.General
  • *
  • Message.Data.*
  • *
  • Message.Data.operation-name where operation-name is one of the following: create, fill get, update, delete, * batched, multi_batch, transacted, page, count, get_or_create, create_and_sequence, get_sequence_id, association_add, * association_remove, fillids, refresh_fill, update_collection
  • *
  • Message.RPC
  • *
  • MessageSelector
  • *
  • Resource
  • *
  • Service.*
  • *
  • Service.Cluster
  • *
  • Service.HTTP
  • *
  • Service.Message
  • *
  • Service.Message.JMS (logs a warning if a durable JMS subscriber can't be unsubscribed successfully.)
  • *
  • Service.Remoting
  • *
  • Security
  • *
* * @author Isaac Levin */ public class CommonsLoggingTarget extends AbstractTarget { protected String categoryPrefix; public CommonsLoggingTarget() { super(); this.categoryPrefix = null; } @Override public void initialize(String id, ConfigMap properties) { super.initialize(id, properties); this.categoryPrefix = properties.getPropertyAsString("categoryPrefix", null); } public void logEvent(LogEvent logevent) { String category = logevent.logger.getCategory(); if (this.categoryPrefix != null) { category = this.categoryPrefix + "." + category; } Log log = LogFactory.getLog(category); switch (logevent.level) { case LogEvent.FATAL: if (log.isFatalEnabled()) { log.fatal(logevent.message, logevent.throwable); } break; case LogEvent.ERROR: if (log.isErrorEnabled()) { log.error(logevent.message, logevent.throwable); } break; case LogEvent.WARN: if (log.isWarnEnabled()) { log.warn(logevent.message, logevent.throwable); } break; case LogEvent.INFO: if (log.isInfoEnabled()) { log.info(logevent.message, logevent.throwable); } break; case LogEvent.DEBUG: if (log.isDebugEnabled()) { log.debug(logevent.message, logevent.throwable); } break; case LogEvent.ALL: if (log.isTraceEnabled()) { log.trace(logevent.message, logevent.throwable); } break; default: break; } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy