Examples of LoggerRepository


Examples of org.apache.log4j.spi.LoggerRepository

    Connection connection = null;

    try {
      Logger logger;
      LoggerRepository loggerRepository = parentDBReceiver
          .getLoggerRepository();
      connection = parentDBReceiver.connectionSource.getConnection();

      StringBuffer sql = new StringBuffer();
      sql.append("SELECT ");
View Full Code Here

Examples of org.apache.log4j.spi.LoggerRepository

        FileInputStream fileStream;
        if(fileName.startsWith("log4j")) {
            String[] strings = fileName.split("_");
            if(strings.length==3) {
                LoggerRepository loggerRepository = LogManager.getLoggerRepository();
                org.apache.log4j.Logger logger4j = loggerRepository.getLogger(strings[1]);
                if(logger4j != null) {
                    LOG.debug(logger4j.getName());
                    LOG.debug(logger4j.getAppender(strings[2]));
                    URL resource = Thread.currentThread().getContextClassLoader().getResource(
                            ((FileAppender) logger4j.getAppender(strings[2])).getFile());
View Full Code Here

Examples of org.apache.log4j.spi.LoggerRepository

    public LoggerRepository getLoggerRepository()
    {
        final ClassLoader ccl = Thread.currentThread().getContextClassLoader();

        LoggerRepository repository = this.repository.get(ccl == null ? NO_CCL_CLASSLOADER : ccl.hashCode());
        if (repository == null)
        {
            final RootLogger root = new RootLogger(Level.INFO);
            repository = new Hierarchy(root);

            try
            {
                ConfigWatchDog configWatchDog = null;
                if (ccl instanceof MuleApplicationClassLoader)
                {
                    MuleApplicationClassLoader muleCL = (MuleApplicationClassLoader) ccl;
                    // check if there's an app-specific logging configuration available,
                    // scope the lookup to this classloader only, as getResource() will delegate to parents
                    // locate xml config first, fallback to properties format if not found
                    URL appLogConfig = muleCL.findResource("log4j.xml");
                    if (appLogConfig == null)
                    {
                        appLogConfig = muleCL.findResource("log4j.properties");
                    }
                    final String appName = muleCL.getAppName();
                    if (appLogConfig == null)
                    {
                        // fallback to defaults
                        String logName = String.format("mule-app-%s.log", appName);
                        File logDir = new File(MuleContainerBootstrapUtils.getMuleHome(), "logs");
                        File logFile = new File(logDir, logName);
                        DailyRollingFileAppender fileAppender = new DailyRollingFileAppender(new PatternLayout(PATTERN_LAYOUT), logFile.getAbsolutePath(), "'.'yyyy-MM-dd");
                        fileAppender.setAppend(true);
                        fileAppender.activateOptions();
                        root.addAppender(fileAppender);
                    }
                    else
                    {
                        configureFrom(appLogConfig, repository);
                        if (appLogConfig.toExternalForm().startsWith("file:"))
                        {
                            // if it's not a file, no sense in monitoring it for changes
                            configWatchDog = new ConfigWatchDog(muleCL, appLogConfig.getFile(), repository);
                            configWatchDog.setName(String.format("[%s].log4j.config.monitor", appName));
                        }
                        else
                        {
                            if (logger.isInfoEnabled())
                            {
                                logger.info(String.format("Logging config %s is not an external file, will not be monitored for changes", appLogConfig));
                            }
                        }
                    }
                }
                else
                {
                    // this is not an app init, but a Mule container, use the top-level defaults
                    File defaultSystemLog = new File(MuleContainerBootstrapUtils.getMuleHome(), "conf/log4j.xml");
                    if (!defaultSystemLog.exists() && !defaultSystemLog.canRead())
                    {
                        defaultSystemLog = new File(MuleContainerBootstrapUtils.getMuleHome(), "conf/log4j.properties");
                    }
                    configureFrom(defaultSystemLog.toURL(), repository);
                    configWatchDog = new ConfigWatchDog(ccl, defaultSystemLog.getAbsolutePath(), repository);
                    configWatchDog.setName("Mule.system.log4j.config.monitor");
                }

                final LoggerRepository previous = this.repository.putIfAbsent(ccl == null ? NO_CCL_CLASSLOADER : ccl.hashCode(), repository);
                if (previous != null)
                {
                    repository = previous;
                }
View Full Code Here

Examples of org.apache.log4j.spi.LoggerRepository

      // Add the root logger to the Hierarchy MBean
      hdm.addLoggerMBean(Logger.getRootLogger().getName());

      // Get each logger from the Log4J Repository and add it to
      // the Hierarchy MBean created above.
      LoggerRepository r = LogManager.getLoggerRepository();

      java.util.Enumeration loggers = r.getCurrentLoggers();

      int count = 1;
      while (loggers.hasMoreElements())
      {
        String name = ((Logger) loggers.nextElement()).getName();
View Full Code Here

Examples of org.apache.log4j.spi.LoggerRepository

     *
     */
    protected void buildNormalContext(Portlet portlet, Context context, RunData rundata) throws Exception
    {
        String tempName;
        LoggerRepository repos = logger.getLoggerRepository();
        Enumeration loggerEnum = repos.getCurrentLoggers();
        HashMap files = new HashMap();
        HashMap fileNames = new HashMap();
        appenders = new HashMap();
       
        while ( loggerEnum.hasMoreElements() )
View Full Code Here

Examples of org.apache.log4j.spi.LoggerRepository

     *
     */
    protected void buildNormalContext(Portlet portlet, Context context, RunData rundata) throws Exception
    {
        String tempName;
        LoggerRepository repos = logger.getLoggerRepository();
        Enumeration loggerEnum = repos.getCurrentLoggers();
        HashMap files = new HashMap();
        HashMap fileNames = new HashMap();
        appenders = new HashMap();
       
        while ( loggerEnum.hasMoreElements() )
View Full Code Here

Examples of org.apache.log4j.spi.LoggerRepository

    String tcfBindingName = args[0];
    String topicBindingName = args[1];
    PropertyConfigurator.configure(args[2]);
   
    LoggerRepository rep = LogManager.getLoggerRepository();
    if(rep instanceof RendererSupport) {
      ((RendererSupport) rep).setRenderer(Message.class, new MessageRenderer());
    }

    try {
View Full Code Here

Examples of org.apache.log4j.spi.LoggerRepository

            System.out.println("Getting stock quote...");
            XMLStreamReader request = factory.createXMLStreamReader(new StringReader(STOCK_QUOTE_REQUEST));

            // temporarily disable INFO logging before calling the web service
            LoggerRepository repository = LogManager.getLoggerRepository();
            Level threshold = repository.getThreshold();
            repository.setThreshold(Level.WARN);

            // first try to get a live stock quote from the web service
            String xml = null;
            try {
                // set a small timeout value in case the server doesn't respond
                Axis2BindingInvoker.GLOBAL_AXIS_TIMEOUT = 8000L;

                OMElement quotes = stockQuote.GetQuote(request);
                xml = quotes.getText();
                if (!xml.startsWith("<")) {
                    System.out.println("Server responded: " + xml);
                    throw new IllegalStateException("Unexpected response from server");
                }
            } catch (ServiceRuntimeException e) {
                // server isn't available, use local historical data
           
            // restore the previous logging setting
            } finally {
                repository.setThreshold(threshold);
            }

            // if the web service invocation was successful, process the response
            XMLStreamReader qts = null;
            if (xml != null) {
View Full Code Here

Examples of org.apache.log4j.spi.LoggerRepository

        assertThat(personService1, is(sameInstance(personService2)));
    }

    @Test
    public void bindsAlternatePackage() {
        LoggerRepository string = injector.getInstance(LoggerRepository.class);
        assertThat(string, is(notNullValue()));
    }
View Full Code Here

Examples of org.apache.log4j.spi.LoggerRepository

    String tcfBindingName = args[0];
    String topicBindingName = args[1];
    PropertyConfigurator.configure(args[2]);

    LoggerRepository rep = LogManager.getLoggerRepository();
    if(rep instanceof RendererSupport) {
      ((RendererSupport) rep).setRenderer(Message.class, new MessageRenderer());
    }

    try {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.