Java Code Examples for org.slf4j.LoggerFactory

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project ATHENA, under directory /core/apa/src/main/java/org/fracturedatlas/athena/apa/impl/jpa/.

Source file: TicketProp.java

  17 
vote

/** 
 * A convenience method for calling compareTo.  It wall also conveniently eat any ClassCastExceptions or IllegalArgumentExceptions that arise from the caller sending in uncastable data (which is, unfortunately, a probable scenario)
 */
public Boolean valueEquals(Object o){
  Boolean isSame=Boolean.FALSE;
  try {
    isSame=compareTo(o) == 0;
  }
 catch (  ClassCastException e) {
    Logger logger=LoggerFactory.getLogger(this.getClass().getName());
    logger.error(e.getMessage(),e);
  }
catch (  IllegalArgumentException e) {
    Logger logger=LoggerFactory.getLogger(this.getClass().getName());
    logger.error(e.getMessage(),e);
  }
  return isSame;
}
 

Example 2

From project airlift, under directory /log/src/main/java/io/airlift/log/.

Source file: Logging.java

  15 
vote

/** 
 * Sets up default logging: <p/> - INFO level - Log entries are written to stderr
 */
public Logging(){
  root=(ch.qos.logback.classic.Logger)LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
  context=(LoggerContext)LoggerFactory.getILoggerFactory();
  context.reset();
  root.setLevel(Level.INFO);
  rewireStdStreams();
  redirectJULToSLF4j();
}
 

Example 3

From project almira-sample, under directory /almira-sample-core/src/main/java/almira/sample/util/.

Source file: LogPostProcessor.java

  15 
vote

@Override public Object postProcessBeforeInitialization(final Object bean,String beanName){
  ReflectionUtils.doWithFields(bean.getClass(),new FieldCallback(){
    @Override public void doWith(    Field field) throws IllegalAccessException {
      ReflectionUtils.makeAccessible(field);
      if (field.getAnnotation(Log.class) != null) {
        Logger logger=LoggerFactory.getLogger(bean.getClass().getName());
        field.set(bean,logger);
      }
    }
  }
);
  return bean;
}
 

Example 4

From project anadix, under directory /anadix-api/src/main/java/org/anadix/factories/.

Source file: FileSource.java

  15 
vote

/** 
 * {@inheritDoc}
 */
public InputStream getStream(){
  try {
    return new FileInputStream(source);
  }
 catch (  FileNotFoundException e) {
    LoggerFactory.getLogger(getClass()).error("Unable to find file",e);
    throw new RuntimeException("Unable to find file",e);
  }
}
 

Example 5

From project ANNIS, under directory /annis-gui/src/main/java/annis/gui/.

Source file: MainApp.java

  15 
vote

protected void initLogging(){
  SLF4JBridgeHandler.removeHandlersForRootLogger();
  SLF4JBridgeHandler.install();
  try {
    ClassResource res=new ClassResource("logback.xml",this);
    if (res != null) {
      LoggerContext context=(LoggerContext)LoggerFactory.getILoggerFactory();
      JoranConfigurator jc=new JoranConfigurator();
      jc.setContext(context);
      context.reset();
      context.putProperty("webappHome",getContext().getBaseDirectory().getAbsolutePath());
      jc.doConfigure(res.getStream().getStream());
    }
  }
 catch (  JoranException ex) {
    log.error("init logging failed",ex);
  }
}
 

Example 6

From project asterisk-java, under directory /src/main/java/org/asteriskjava/util/internal/.

Source file: Slf4JLogger.java

  15 
vote

/** 
 * Return the native Logger instance we are using.
 */
public final Logger getLogger(){
  if (logger == null) {
    logger=LoggerFactory.getLogger(clazz);
  }
  return (this.logger);
}
 

Example 7

From project cas, under directory /cas-server-core/src/main/java/org/jasig/cas/aspect/.

Source file: LogAspect.java

  15 
vote

protected Logger getLog(final JoinPoint joinPoint){
  final Object target=joinPoint.getTarget();
  if (target != null) {
    return LoggerFactory.getLogger(target.getClass());
  }
  return LoggerFactory.getLogger(getClass());
}
 

Example 8

From project cdi-extension-showcase, under directory /src/main/java/com/acme/logging/.

Source file: LoggerProducer.java

  15 
vote

@Produces @Category public Logger produceLog(InjectionPoint injectionPoint){
  String category=null;
  category=injectionPoint.getAnnotated().getAnnotation(Category.class).value();
  if (category.isEmpty()) {
    category=injectionPoint.getMember().getDeclaringClass().getName();
  }
  return LoggerFactory.getLogger(category);
}
 

Example 9

From project cometd, under directory /cometd-java/cometd-java-oort/src/main/java/org/cometd/oort/.

Source file: Oort.java

  15 
vote

public Oort(BayeuxServer bayeux,String url){
  _bayeux=bayeux;
  _url=url;
  _id=UUID.randomUUID().toString();
  _logger=LoggerFactory.getLogger(getClass().getName() + "." + _url);
  _debug=String.valueOf(BayeuxServerImpl.DEBUG_LOG_LEVEL).equals(bayeux.getOption(BayeuxServerImpl.LOG_LEVEL));
  _oortSession=bayeux.newLocalSession("oort");
  _secret=Long.toHexString(new SecureRandom().nextLong());
}
 

Example 10

From project dawn-workflow, under directory /org.dawb.workbench.jmx/src/org/dawb/workbench/jmx/example/.

Source file: WorkflowExample.java

  15 
vote

/** 
 * Example of how to configure log4j if needed.
 */
private static final void createLoggingProperties(){
  if (System.getProperty("logback.configurationFile") == null) {
    final URL url=WorkflowExample.class.getResource("logback.xml");
    System.setProperty("logback.configurationFile",url.getFile());
  }
  logger=LoggerFactory.getLogger(WorkflowExample.class);
}
 

Example 11

From project DirectMemory, under directory /server/directmemory-server-client/src/main/java/org/apache/directmemory/server/client/.

Source file: AbstractDirectMemoryHttpClient.java

  15 
vote

public static DirectMemoryResponse buildResponse(InputStream inputStream,DirectMemoryRequest request) throws DirectMemoryException {
switch (request.getExchangeType()) {
case JSON:
    return DirectMemoryParser.instance().buildResponse(inputStream);
case JAVA_SERIALIZED_OBJECT:
  try {
    DirectMemoryResponse response=new DirectMemoryResponse();
    response.setResponse(request.getSerializer().deserialize(IOUtils.toByteArray(inputStream),request.getObjectClass()));
    return response;
  }
 catch (  IOException e) {
    throw new DirectMemoryException(e.getMessage(),e);
  }
catch (  ClassNotFoundException e) {
    throw new DirectMemoryException(e.getMessage(),e);
  }
catch (  IllegalAccessException e) {
    throw new DirectMemoryException(e.getMessage(),e);
  }
catch (  InstantiationException e) {
    throw new DirectMemoryException(e.getMessage(),e);
  }
case TEXT_PLAIN:
try {
  DirectMemoryResponse<String> response=new DirectMemoryResponse<String>();
  response.setResponse(IOUtils.toString(inputStream));
  return response;
}
 catch (IOException e) {
  throw new DirectMemoryException(e.getMessage(),e);
}
default :
LoggerFactory.getLogger(AbstractDirectMemoryHttpClient.class).error("exchange type unknown {}",request.getExchangeType());
throw new DirectMemoryException("exchange type unknown " + request.getExchangeType());
}
}
 

Example 12

From project droolsjbpm-integration, under directory /drools-container/drools-spring/src/test/java/org/jbpm/task/service/test/spring/.

Source file: BaseSpringNoUserGroupSetupTest.java

  15 
vote

@Before public void setUp() throws Exception {
  removeAllTasks();
  logger=LoggerFactory.getLogger(getClass());
  MockUserInfo userInfo=new MockUserInfo();
  taskService.setUserinfo(userInfo);
  users=fillUsersOrGroups("LoadUsers.mvel");
  groups=fillUsersOrGroups("LoadGroups.mvel");
  taskService.addUsersAndGroups(users,groups);
  server=startServer(taskService);
  client=new TaskClient(createTestTaskClientConnector("client 1",(TestTaskServer)server));
  client.connect();
  taskSession=taskService.createSession();
  if (!UserGroupCallbackManager.getInstance().existsCallback()) {
    UserGroupCallbackManager.getInstance().setCallback(new UserGroupCallbackOneImpl());
  }
  taskSession.addUser(new User("Administrator"));
}
 

Example 13

From project fiftyfive-wicket, under directory /fiftyfive-wicket-core/src/main/java/fiftyfive/wicket/.

Source file: FoundationApplication.java

  15 
vote

/** 
 * Enables Wicket's request logging facility if an SLF4J logger is configured for  {@code INFO} with the category{@code org.apache.wicket.protocol.http.RequestLogger}. For example, if using log4j properties configuration, this would cause the Wicket request logger to be enabled: <pre class="example"> log4j.logger.org.apache.wicket.protocol.http.RequestLogger = INFO</pre>
 * @since 2.0
 */
protected void initRequestLogger(){
  Logger log=LoggerFactory.getLogger(RequestLogger.class);
  if (log.isInfoEnabled()) {
    getRequestLoggerSettings().setRequestLoggerEnabled(true);
  }
}
 

Example 14

From project flatpack-java, under directory /core/src/main/java/com/getperka/flatpack/inject/.

Source file: FlatPackModule.java

  15 
vote

@Override protected void configure(){
  bindExposedTypes();
  bind(Logger.class).annotatedWith(FlatPackLogger.class).toInstance(LoggerFactory.getLogger(FlatPack.class));
  bind(IoObserver.class).to(configuration.isVerbose() ? IoObserver.Verbose.class : IoObserver.Null.class);
  bindConstant().annotatedWith(IgnoreUnresolvableTypes.class).to(configuration.isIgnoreUnresolvableTypes());
  bindConstant().annotatedWith(PrettyPrint.class).to(configuration.isPrettyPrint());
  bindConstant().annotatedWith(Verbose.class).to(configuration.isVerbose());
  bindConstant().annotatedWith(VerboseLogChunkSize.class).to(configuration.getVerboseLogChunkSize());
  bind(new TypeLiteral<Collection<Class<?>>>(){
  }
).annotatedWith(AllTypes.class).toInstance(configuration.getAllTypes());
  bindImplementationTypes();
  bindPackScope();
  bindUserTypes();
}
 

Example 15

From project floodlight, under directory /src/main/java/net/floodlightcontroller/firewall/.

Source file: Firewall.java

  15 
vote

@Override public void init(FloodlightModuleContext context) throws FloodlightModuleException {
  floodlightProvider=context.getServiceImpl(IFloodlightProviderService.class);
  storageSource=context.getServiceImpl(IStorageSourceService.class);
  restApi=context.getServiceImpl(IRestApiService.class);
  rules=new ArrayList<FirewallRule>();
  logger=LoggerFactory.getLogger(Firewall.class);
  enabled=false;
}
 

Example 16

From project framework, under directory /impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/proxy/.

Source file: Slf4jLoggerProxy.java

  15 
vote

private Logger getDelegate(){
  if (delegate == null) {
    delegate=LoggerFactory.getLogger(type);
  }
  return delegate;
}
 

Example 17

From project gda-common, under directory /uk.ac.gda.common/src/gda/util/logging/.

Source file: LogbackUtils.java

  15 
vote

/** 
 * Returns the default Logback logger context. <p>This method can be used instead of calling  {@link LoggerFactory#getILoggerFactory()} directly and casting theresult to a Logback  {@link LoggerContext}. It assumes that Logback is being used, so that the singleton SLF4J logger factory can be cast to a Logback  {@link LoggerContext}. If a  {@link ClassCastException} occurs, a moreuseful exception will be thrown instead.
 * @return the Logback logger context
 */
public static LoggerContext getLoggerContext(){
  try {
    return (LoggerContext)LoggerFactory.getILoggerFactory();
  }
 catch (  ClassCastException e) {
    final String msg="Couldn't cast the logger factory to a Logback LoggerContext. Perhaps you aren't using Logback?";
    throw new RuntimeException(msg,e);
  }
}
 

Example 18

From project gitblit, under directory /src/com/gitblit/utils/.

Source file: MarkdownUtils.java

  15 
vote

/** 
 * Returns the html version of the markdown source reader. The reader is closed regardless of success or failure.
 * @param markdownReader
 * @return html version of the markdown text
 * @throws java.text.ParseException
 */
public static String transformMarkdown(Reader markdownReader) throws java.text.ParseException {
  StringWriter writer=new StringWriter();
  try {
    Markdown md=new Markdown();
    md.transform(markdownReader,writer);
    return writer.toString().trim();
  }
 catch (  StringIndexOutOfBoundsException e) {
    LoggerFactory.getLogger(MarkdownUtils.class).error("MarkdownPapers failed to parse Markdown!",e);
    throw new java.text.ParseException(e.getMessage(),0);
  }
catch (  ParseException p) {
    LoggerFactory.getLogger(MarkdownUtils.class).error("MarkdownPapers failed to parse Markdown!",p);
    throw new java.text.ParseException(p.getMessage(),0);
  }
catch (  Exception e) {
    LoggerFactory.getLogger(MarkdownUtils.class).error("MarkdownPapers failed to parse Markdown!",e);
    throw new java.text.ParseException(e.getMessage(),0);
  }
 finally {
    try {
      writer.close();
    }
 catch (    IOException e) {
    }
  }
}
 

Example 19

From project GNDMS, under directory /infra/test-src/de/zib/gndms/infra/configlet/.

Source file: C3MDSConfigletSoloTest.java

  15 
vote

@Test public void testC3MDS(){
  Logger log=LoggerFactory.getLogger("test");
  HashMap<String,String> configMap=Maps.newHashMap();
  configMap.put("delay","10000");
  configMap.put("initialDelay","1000");
  configMap.put("mdsUrl","http://c3grid-gt.e-technik.uni-dortmund.de:8080/webmds/webmds?info=indexinfo");
  C3MDSConfiglet configlet=new C3MDSConfiglet();
  configlet.init(log,"c3mds",configMap);
  try {
    Thread.sleep(23000L);
  }
 catch (  InterruptedException e) {
    e.printStackTrace();
  }
  configlet.shutdown();
}
 

Example 20

From project goldenorb, under directory /src/main/java/org/goldenorb/io/.

Source file: InputSplitAllocator.java

  15 
vote

/** 
 * Constructor
 * @param orbConf
 * @param orbPartitionMembers
 */
public InputSplitAllocator(OrbConfiguration orbConf,Collection<OrbPartitionMember> orbPartitionMembers){
  this.orbConf=orbConf;
  this.orbPartitionMembers=orbPartitionMembers;
  LOG=LoggerFactory.getLogger(InputSplitAllocator.class);
  for (  OrbPartitionMember orbPartitionMember : orbPartitionMembers) {
    if (!hostToRawSplitCount.containsKey(orbPartitionMember.getHostname())) {
      hostToRawSplitCount.put(orbPartitionMember.getHostname(),0);
    }
    if (!hostToPortToRawSplits.containsKey(orbPartitionMember.getHostname())) {
      hostToPortToRawSplits.put(orbPartitionMember.getHostname(),new HashMap<Integer,List<RawSplit>>());
    }
    Map<Integer,List<RawSplit>> portMap=hostToPortToRawSplits.get(orbPartitionMember.getHostname());
    if (!portMap.containsKey(orbPartitionMember.getPort())) {
      portMap.put(orbPartitionMember.getPort(),new ArrayList<RawSplit>());
    }
  }
}
 

Example 21

From project griffon, under directory /subprojects/griffon-rt/src/main/groovy/org/codehaus/griffon/runtime/core/.

Source file: AbstractGriffonApplication.java

  15 
vote

public AbstractGriffonApplication(String[] args){
  startupArgs=new String[args.length];
  System.arraycopy(args,0,startupArgs,0,args.length);
  ApplicationHolder.setApplication(this);
  log=LoggerFactory.getLogger(getClass());
  MVCGroupExceptionHandler.registerWith(this);
}
 

Example 22

From project ha-jdbc, under directory /src/main/java/net/sf/hajdbc/logging/slf4j/.

Source file: SLF4JLoggingProvider.java

  15 
vote

/** 
 * {@inheritDoc}
 * @see net.sf.hajdbc.logging.LoggingProvider#isEnabled()
 */
@Override public boolean isEnabled(){
  try {
    return !LoggerFactory.getILoggerFactory().getClass().equals(NOPLoggerFactory.class);
  }
 catch (  Throwable e) {
    return false;
  }
}
 

Example 23

From project hadoop-book_1, under directory /src/main/java/com/manning/hip/ch12/crunch/.

Source file: CrunchUtils.java

  15 
vote

public static PCollection<CommonLogEntry> logs(PCollection<String> lines){
  PTypeFamily tf=lines.getTypeFamily();
  return lines.parallelDo(new DoFn<String,CommonLogEntry>(){
    transient ApacheCommonLogReader logReader;
    transient Logger log;
    @Override public void initialize(){
      logReader=new ApacheCommonLogReader();
      log=LoggerFactory.getLogger(CrunchUtils.class);
    }
    @Override public void process(    String input,    Emitter<CommonLogEntry> emitter){
      try {
        CommonLogEntry log=logReader.decodeLine(input);
        if (log != null) {
          emitter.emit(log);
        }
 else {
          processingError(input,null);
        }
      }
 catch (      IOException e) {
        processingError(input,e);
      }
    }
    void processingError(    String line,    @Nullable Throwable t){
      super.getCounter(LogCounters.LOG_LINE_ERRORS).increment(1);
      log.error("Hit exception parsing line '" + line + "'",t);
    }
  }
,tf.records(CommonLogEntry.class));
}
 

Example 24

From project hbase-rdf_1, under directory /src/main/java/com/talis/hbase/rdf/store/.

Source file: LayoutType.java

  15 
vote

public static LayoutType fetch(String layoutTypeName){
  if (layoutTypeName == null)   throw new IllegalArgumentException("LayoutType.convert: null not allowed");
  LayoutType t=registry.lookup(layoutTypeName);
  if (t != null)   return t;
  LoggerFactory.getLogger(LayoutType.class).warn("Can't turn '" + layoutTypeName + "' into a layout type");
  throw new HBaseRdfException("Can't turn '" + layoutTypeName + "' into a layout type");
}
 

Example 25

From project hoop, under directory /hoop-server/src/main/java/com/cloudera/lib/server/.

Source file: Server.java

  15 
vote

/** 
 * Initializes Log4j logging.
 * @throws ServerException thrown if Log4j could not be initialized.
 */
protected void initLog() throws ServerException {
  verifyDir(logDir);
  LogManager.resetConfiguration();
  File log4jFile=new File(configDir,name + "-log4j.properties");
  if (log4jFile.exists()) {
    PropertyConfigurator.configureAndWatch(log4jFile.toString(),10 * 1000);
    log=LoggerFactory.getLogger(Server.class);
  }
 else {
    Properties props=new Properties();
    try {
      InputStream is=ClassUtils.getResource(DEFAULT_LOG4J_PROPERTIES);
      props.load(is);
    }
 catch (    IOException ex) {
      throw new ServerException(ServerException.ERROR.S03,DEFAULT_LOG4J_PROPERTIES,ex.getMessage(),ex);
    }
    PropertyConfigurator.configure(props);
    log=LoggerFactory.getLogger(Server.class);
    log.warn("Log4j [{}] configuration file not found, using default configuration from classpath",log4jFile);
  }
}
 

Example 26

From project https-utils, under directory /src/main/java/org/italiangrid/utils/https/.

Source file: JettyRunThread.java

  15 
vote

/** 
 * {@inheritDoc} 
 */
public void run(){
  try {
    httpServer.start();
    httpServer.join();
  }
 catch (  Exception e) {
    Logger log=LoggerFactory.getLogger(JettyRunThread.class);
    log.error("Unable to start service, shutting down",e);
    e.printStackTrace();
    System.exit(1);
  }
}
 

Example 27

From project incubator-s4, under directory /subprojects/s4-comm/src/main/java/org/apache/s4/comm/udp/.

Source file: UDPEmitter.java

  15 
vote

@Override public boolean send(int partitionId,EventMessage eventMessage){
  try {
    byte[] message=serDeser.serialize(eventMessage);
    ClusterNode node=nodes.get(partitionId);
    if (node == null) {
      LoggerFactory.getLogger(getClass()).error("Cannot send message to partition {} because this partition is not visible to this emitter",partitionId);
      return false;
    }
    byte[] byteBuffer=new byte[message.length];
    System.arraycopy(message,0,byteBuffer,0,message.length);
    InetAddress inetAddress=inetCache.get(partitionId);
    if (inetAddress == null) {
      inetAddress=InetAddress.getByName(node.getMachineName());
      inetCache.put(partitionId,inetAddress);
    }
    DatagramPacket dp=new DatagramPacket(byteBuffer,byteBuffer.length,inetAddress,node.getPort());
    socket.send(dp);
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
  return true;
}
 

Example 28

From project iudex_1, under directory /iudex-filter/src/main/java/iudex/filter/core/.

Source file: LogListener.java

  15 
vote

public LogListener(String logBase,FilterIndex index){
  _logAccept=LoggerFactory.getLogger(logBase + ".accept");
  _logReject=LoggerFactory.getLogger(logBase + ".reject");
  _logFailed=LoggerFactory.getLogger(logBase + ".failed");
  _index=index;
}
 

Example 29

From project jackrabbit-oak, under directory /oak-core/src/main/java/org/apache/jackrabbit/oak/util/.

Source file: TODO.java

  15 
vote

private TODO(String message){
  this.exception=new UnsupportedOperationException(message);
  StackTraceElement[] trace=exception.getStackTrace();
  if (trace != null && trace.length > 2) {
    String className=trace[2].getClassName();
    String methodName=trace[2].getMethodName();
    this.logger=LoggerFactory.getLogger(className);
    this.message="TODO: " + className + "."+ methodName+ "() - "+ message;
  }
 else {
    this.logger=LoggerFactory.getLogger(TODO.class);
    this.message="TODO: " + message;
  }
}
 

Example 30

From project james, under directory /data-file/src/test/java/org/apache/james/domainlist/xml/.

Source file: XMLDomainListTest.java

  15 
vote

@Test public void testNoConfiguredDomains() throws Exception {
  List<String> domains=new ArrayList<String>();
  XMLDomainList dom=new XMLDomainList();
  dom.setLog(LoggerFactory.getLogger("MockLog"));
  dom.configure(setUpConfiguration(false,false,domains));
  dom.setDNSService(setUpDNSServer("localhost"));
  assertNull("No domain found",dom.getDomains());
}
 

Example 31

From project james-mailbox, under directory /api/src/test/java/org/apache/james/mailbox/.

Source file: AbstractMailboxManagerTest.java

  15 
vote

@Test public void testBasicOperations() throws BadCredentialsException, MailboxException, UnsupportedEncodingException {
  setMailboxManager(new MockMailboxManager(getMailboxManager()).getMockMailboxManager());
  MailboxSession session=getMailboxManager().createSystemSession(USER_1,LoggerFactory.getLogger("Mock"));
  Assert.assertEquals(USER_1,session.getUser().getUserName());
  getMailboxManager().startProcessingRequest(session);
  MailboxPath inbox=MailboxPath.inbox(session);
  Assert.assertFalse(getMailboxManager().mailboxExists(inbox,session));
  getMailboxManager().createMailbox(inbox,session);
  Assert.assertTrue(getMailboxManager().mailboxExists(inbox,session));
  try {
    getMailboxManager().createMailbox(inbox,session);
    Assert.fail();
  }
 catch (  MailboxException e) {
  }
  MailboxPath inboxSubMailbox=new MailboxPath(inbox,"INBOX.Test");
  Assert.assertFalse(getMailboxManager().mailboxExists(inboxSubMailbox,session));
  getMailboxManager().createMailbox(inboxSubMailbox,session);
  Assert.assertTrue(getMailboxManager().mailboxExists(inboxSubMailbox,session));
  getMailboxManager().deleteMailbox(inbox,session);
  Assert.assertFalse(getMailboxManager().mailboxExists(inbox,session));
  Assert.assertTrue(getMailboxManager().mailboxExists(inboxSubMailbox,session));
  getMailboxManager().deleteMailbox(inboxSubMailbox,session);
  Assert.assertFalse(getMailboxManager().mailboxExists(inboxSubMailbox,session));
  getMailboxManager().logout(session,false);
  getMailboxManager().endProcessingRequest(session);
  Assert.assertFalse(session.isOpen());
}
 

Example 32

From project java-sql-generator, under directory /implementation/src/main/java/org/sql/generation/implementation/transformation/.

Source file: QueryProcessing.java

  15 
vote

@Override protected void doProcess(SQLProcessorAggregator processor,QuerySpecification query,StringBuilder builder){
  processor.process(query.getColumns(),builder);
  processor.process(query.getFrom(),builder);
  QueryProcessing.processOptionalBooleanExpression(processor,builder,query.getWhere(),SQLConstants.NEWLINE,SQLConstants.WHERE);
  processor.process(query.getGroupBy(),builder);
  QueryProcessing.processOptionalBooleanExpression(processor,builder,query.getHaving(),SQLConstants.NEWLINE,SQLConstants.HAVING);
  processor.process(query.getOrderBy(),builder);
  Typeable<?> first=null;
  Typeable<?> second=null;
  if (this.isOffsetBeforeLimit(processor)) {
    first=query.getOffsetSpecification();
    second=query.getLimitSpecification();
  }
 else {
    first=query.getLimitSpecification();
    second=query.getOffsetSpecification();
  }
  if (first != null || second != null) {
    this.processLimitAndOffset(processor,builder,first,second);
  }
  if (query.getOrderBy() == null && (query.getOffsetSpecification() != null || query.getLimitSpecification() != null)) {
    LoggerFactory.getLogger(this.getClass().getName()).warn("Spotted query with " + SQLConstants.OFFSET_PREFIX + " and/or "+ SQLConstants.LIMIT_PREFIX+ " clause, but without ORDER BY. The result will be unpredictable!"+ "\n"+ "Query: "+ builder.toString());
  }
}
 

Example 33

From project jboss-logging, under directory /src/main/java/org/jboss/logging/.

Source file: Slf4jLoggerProvider.java

  15 
vote

public Logger getLogger(final String name){
  org.slf4j.Logger l=LoggerFactory.getLogger(name);
  try {
    return new Slf4jLocationAwareLogger(name,(LocationAwareLogger)l);
  }
 catch (  Throwable ignored) {
  }
  return new Slf4jLogger(name,l);
}
 

Example 34

From project jdeltasync, under directory /src/main/java/com/googlecode/jdeltasync/.

Source file: DeltaSyncSession.java

  15 
vote

/** 
 * Returns the  {@link Logger} which will be used by {@link DeltaSyncClient}to log things for this session.
 * @return the {@link Logger}.
 */
public Logger getLogger(){
  if (logger == null) {
    logger=LoggerFactory.getLogger(DeltaSyncSession.class.getName() + "." + username);
  }
  return logger;
}
 

Example 35

From project jena-tdb, under directory /src/main/java/com/hp/hpl/jena/tdb/base/block/.

Source file: BlockMgrLogger.java

  15 
vote

public BlockMgrLogger(Logger log,String label,BlockMgr blockMgr,boolean logAllOperations){
  this.blockMgr=blockMgr;
  if (log == null)   log=LoggerFactory.getLogger(BlockMgr.class);
  this.log=log;
  this.logAllOperations=logAllOperations;
  this.label=label;
}
 

Example 36

From project jentrata-msh, under directory /Clients/Corvus.WSClient/src/test/java/hk/hku/cecid/corvus/http/.

Source file: EnvelopQuerySenderUnitTest.java

  15 
vote

/** 
 * Setup the fixture. 
 */
public void setUp() throws Exception {
  this.initTestData();
  this.initTestTarget();
  logger=LoggerFactory.getLogger(this.getName());
  logger.info(this.getName() + " Start ");
}
 

Example 37

From project jeppetto, under directory /jeppetto-dao-mongo/src/main/java/org/iternine/jeppetto/dao/mongodb/.

Source file: MongoDBQueryModelDAO.java

  15 
vote

@SuppressWarnings({"unchecked"}) protected MongoDBQueryModelDAO(Class<T> entityClass,Map<String,Object> daoProperties,AccessControlContextProvider accessControlContextProvider){
  String collectionName=daoProperties.containsKey("collection") ? (String)daoProperties.get("collection") : entityClass.getSimpleName();
  this.dbCollection=((DB)daoProperties.get("db")).getCollection(collectionName);
  this.enhancer=EnhancerHelper.getDirtyableDBObjectEnhancer(entityClass);
  dbCollection.setObjectClass(enhancer.getEnhancedClass());
  dbCollection.setDBDecoderFactory(new DBDecoderFactory(){
    @Override public DBDecoder create(){
      return new MongoDBDecoder();
    }
  }
);
  this.accessControlContextProvider=accessControlContextProvider;
  this.uniqueIndexes=ensureIndexes((List<String>)daoProperties.get("uniqueIndexes"),true);
  ensureIndexes((List<String>)daoProperties.get("nonUniqueIndexes"),false);
  this.optimisticLockEnabled=Boolean.parseBoolean((String)daoProperties.get("optimisticLockEnabled"));
  this.shardKeys=extractShardKeys((String)daoProperties.get("shardKeyPattern"));
  this.saveNulls=Boolean.parseBoolean((String)daoProperties.get("saveNulls"));
  if (daoProperties.containsKey("writeConcern")) {
    this.defaultWriteConcern=WriteConcern.valueOf((String)daoProperties.get("writeConcern"));
  }
 else {
    this.defaultWriteConcern=WriteConcern.SAFE;
  }
  if (Boolean.parseBoolean((String)daoProperties.get("showQueries"))) {
    queryLogger=LoggerFactory.getLogger(getClass());
  }
}
 

Example 38

From project jmxmonitor, under directory /jmxmonitor/src/main/java/uk/co/gidley/jmxmonitor/monitoring/.

Source file: MonitoringGroup.java

  15 
vote

/** 
 * Called to initialise the monitoring group. The group should use this to construct expensive objects, validate configuration and prepare to run.
 * @param monitorsConfigurationFile	The monitors file
 * @param expressionsConfigurationFile The expression file
 * @param intervalInMilliseconds	   The interval to poll in milliseconds
 */
public void initialise(String name,File monitorsConfigurationFile,File expressionsConfigurationFile,long intervalInMilliseconds) throws InitialisationException {
  try {
    interval=intervalInMilliseconds;
    this.name=name;
    outputLogger=LoggerFactory.getLogger(MONITORING_GROUP + name);
    PropertiesConfiguration propertiesConfiguration=new PropertiesConfiguration();
    propertiesConfiguration.setDelimiterParsingDisabled(monitorsConfiguration.isDelimiterParsingDisabled());
    propertiesConfiguration.setFile(monitorsConfigurationFile);
    propertiesConfiguration.load();
    monitorsConfiguration.addConfiguration(propertiesConfiguration);
    expressionsConfiguration.addConfiguration(new PropertiesConfiguration(expressionsConfigurationFile));
    initialiseMonitors();
    initialiseExpressions();
  }
 catch (  ConfigurationException e) {
    logger.error("{}",e);
    throw new InitialisationException(e);
  }
catch (  MalformedObjectNameException e) {
    logger.error("{}",e);
    throw new InitialisationException(e);
  }
catch (  MalformedURLException e) {
    logger.error("{}",e);
    throw new InitialisationException(e);
  }
}
 

Example 39

From project jnrpe-server, under directory /jnrpe-server/src/main/java/it/jnrpe/server/.

Source file: EventLoggerListener.java

  15 
vote

public void receive(Object sender,IJNRPEEvent event){
  String sClassName=sender.getClass().getName();
  Logger logger=m_mLoggers.get(sClassName);
  if (logger == null) {
    logger=LoggerFactory.getLogger(sender.getClass());
    m_mLoggers.put(sClassName,logger);
  }
  Throwable error=(Throwable)event.getEventParams().get("EXCEPTION");
  String sEventName=event.getEventName();
  if (sEventName.equals("TRACE")) {
    if (error != null)     logger.trace((String)event.getEventParams().get("MESSAGE"),error);
 else     logger.trace((String)event.getEventParams().get("MESSAGE"));
    return;
  }
  if (sEventName.equals("DEBUG")) {
    if (error != null)     logger.debug((String)event.getEventParams().get("MESSAGE"),error);
 else     logger.debug((String)event.getEventParams().get("MESSAGE"));
    return;
  }
  if (sEventName.equals("INFO")) {
    if (error != null)     logger.info((String)event.getEventParams().get("MESSAGE"),error);
 else     logger.info((String)event.getEventParams().get("MESSAGE"));
    return;
  }
  if (sEventName.equals("WARNING")) {
    if (error != null)     logger.warn((String)event.getEventParams().get("MESSAGE"),error);
 else     logger.warn((String)event.getEventParams().get("MESSAGE"));
    return;
  }
  if (sEventName.equals("ERROR")) {
    if (error != null)     logger.error((String)event.getEventParams().get("MESSAGE"),error);
 else     logger.error((String)event.getEventParams().get("MESSAGE"));
    return;
  }
  if (sEventName.equals("FATAL")) {
    if (error != null)     logger.error((String)event.getEventParams().get("MESSAGE"),(Throwable)(event.getEventParams().get("EXCEPTION")));
 else     logger.error((String)event.getEventParams().get("MESSAGE"));
    return;
  }
}
 

Example 40

From project jPOS-EE, under directory /modules/core/src/main/java/org/jpos/logging/logback/.

Source file: LogbackConfigurator.java

  15 
vote

@Override protected void startService() throws Exception {
  LoggerContext context=(LoggerContext)LoggerFactory.getILoggerFactory();
  try {
    JoranConfigurator configurator=new JoranConfigurator();
    configurator.setContext(context);
    context.reset();
    if (configResource.startsWith("file:")) {
      final String f=configResource.substring(5);
      log.info("Reading logback configuration from file: " + f);
      configurator.doConfigure(new File(f));
    }
 else     if (configResource.startsWith("classpath:")) {
      final URL r=getClass().getResource(configResource.substring(10));
      log.info("Reading logback configuration from classpath resource: " + r.toString());
      configurator.doConfigure(r);
    }
  }
 catch (  JoranException je) {
    log.error("Logger configuration exception",je);
  }
  printStatusIfWarningOrError(context);
}
 

Example 41

From project JsTestDriver, under directory /JsTestDriver/src/com/google/jstestdriver/server/handlers/.

Source file: BrowserLoggingHandler.java

  15 
vote

public void handleIt() throws IOException {
  try {
    Collection<BrowserLog> logs=gson.fromJson(request.getParameter("logs"),new TypeToken<Collection<BrowserLog>>(){
    }
.getType());
    for (    BrowserLog log : logs) {
      Logger logger=LoggerFactory.getLogger(log.getSource());
switch (log.getLevel()) {
case 1:
        logger.trace(log.getMessage());
      break;
case 2:
    logger.debug(log.getMessage());
  break;
case 3:
logger.info(log.getMessage());
break;
case 4:
logger.warn(log.getMessage());
break;
case 5:
logger.error(log.getMessage());
break;
default :
throw new RuntimeException("Unknown logging level:" + log.getLevel());
}
}
response.setStatus(HttpStatus.ORDINAL_200_OK);
}
 catch (RuntimeException e) {
response.setStatus(HttpStatus.ORDINAL_500_Internal_Server_Error);
logger.error("Error during BrowserLog write.",e);
}
 finally {
response.getOutputStream().flush();
}
}
 

Example 42

From project kernel_1, under directory /exo.kernel.commons/src/main/java/org/exoplatform/services/log/impl/.

Source file: SLF4JExoLogFactory.java

  15 
vote

/** 
 * {@inheritDoc}
 */
@Override protected Log getLogger(final String name){
  Logger slf4jlogger=SecurityHelper.doPrivilegedAction(new PrivilegedAction<Logger>(){
    public Logger run(){
      return LoggerFactory.getLogger(name);
    }
  }
);
  if (slf4jlogger instanceof LocationAwareLogger) {
    return new LocationAwareSLF4JExoLog((LocationAwareLogger)slf4jlogger);
  }
 else {
    return new SLF4JExoLog(slf4jlogger);
  }
}
 

Example 43

From project lilith, under directory /jul/jul-slf4j-handler/src/main/java/de/huxhorn/lilith/handler/.

Source file: Slf4JHandler.java

  15 
vote

private void logTrace(LogRecord record){
  String loggerName=record.getLoggerName();
  final Logger logger=LoggerFactory.getLogger(loggerName);
  if (logger.isTraceEnabled()) {
    initMDC(record);
    String message=record.getMessage();
    Throwable throwable=record.getThrown();
    if (throwable != null) {
      logger.trace(message,throwable);
    }
 else {
      logger.trace(message);
    }
    clearMDC();
  }
}