GVKun编程网logo

macos – Binutils stat非法选项-c

9

如果您想了解macos–Binutilsstat非法选项-c的知识,那么本篇文章将是您的不二之选。同时我们将深入剖析activerecord–Rails4.1枚举:enum.status=nil、Ap

如果您想了解macos – Binutils stat非法选项-c的知识,那么本篇文章将是您的不二之选。同时我们将深入剖析activerecord – Rails 4.1枚举:enum.status = nil、Apache的BeanUtils和PropertyUtils,Spring的BeanUtils,Cg、Bean 复制的几种框架性能比较(Apache BeanUtils、PropertyUtils,Spring BeanUtils,Cglib BeanCopier、ch.qos.logback.core.status.StatusUtil的实例源码的各个方面,并给出实际的案例分析,希望能帮助到您!

本文目录一览:

macos – Binutils stat非法选项-c

macos – Binutils stat非法选项-c

我在我的脚本中使用两次stat来查找文件文件权限,一次查找文件的大小.
`stat -c %A "$directory/$file"` `stat -c %s "$directory/$file"`

我使用的是OSX 10.7,目录和文件是我所在的当前目录和文件的变量.

解决方法

Darwin stat使用-f参数而不是-c,因为它是GNU扩展.

您应该从homebrew,macports或fink下载gnu binutils,然后使用gstat而不是stat.

如果您不想安装gnu binutils并且更喜欢坚持使用标准BSD工具,那么:

stat -f%p t.c

将返回模式(八进制)和

stat -f%z t.c

将返回大小.

activerecord – Rails 4.1枚举:enum.status = nil

activerecord – Rails 4.1枚举:enum.status = nil

我尝试了rails 4.1的新枚举功能并且遇到了一些麻烦.

我的模型看起来像这样:

class Report < ActiveRecord::Base
  after_save :notify_clients
  before_update :update_progress
  before_create do
    self.status ||= 'started'
  end

  enum status: %w{started active fail success}

  #...
end

如果我尝试在我看来这样使用它:

.item{class: @report.status,data: {id: @report.id}}

我会在浏览器中看到这个

<divdata-id="25">

我试图找出使用rails console的实际状态:

[11] pry(main)> Report.all.sample.status
    Report Load (0.3ms)  SELECT `reports`.* FROM `reports`
  => nil
  [12] pry(main)> Report.all.sample.status
    Report Load (0.2ms)  SELECT `reports`.* FROM `reports`
  => nil
  [13] pry(main)> Report.all.sample.status
    Report Load (0.3ms)  SELECT `reports`.* FROM `reports`
  => nil
  [14] pry(main)> Report.all.sample.status
    Report Load (0.2ms)  SELECT `reports`.* FROM `reports`
  => nil

现在看看这个:

[22] pry(main)> Report.all.sample.attributes['status']
    Report Load (0.2ms)  SELECT `reports`.* FROM `reports`
  => "3"

我不明白……

解决方法

我有同样的问题.之所以这是因为枚举字段在我的模式中定义为字符串而不是整数.在您的情况下,状态可能被定义为架构中的字符串.
class CreateReport < ActiveRecord::Migration
  def change
    create_table :reports do |t|
      ...
      t.integer :status     # if this is t.string you get the symptoms described above!
      ...
    end
  end
end

Apache的BeanUtils和PropertyUtils,Spring的BeanUtils,Cg

Apache的BeanUtils和PropertyUtils,Spring的BeanUtils,Cg

作为一个新员工,一个首要的工作就是阅读别人的代码,阅读代码的诸多好处就不说了,我就直奔主题,通过预读代码,发现了几种实现两个不同类型的Bean之间实现值复制的几种方式,上网查询后发现性能上会有差异,于是就萌生自己深入了解几种实现的想法。第一步就是先本着实事求是的原则去探求一下大家总结出来的性能差异是否正确。

       比较的是四种复制的方式,分别为Apache的BeanUtils和PropertyUtils,Spring的BeanUtils,Cglib的BeanCopier。做法是在Eclipse新建了一个Project,专门用于专门测试几种代码的性能。具体的代码如下:

       一个FromBean和一个ToBean,两个的代码基本上一样,除了类名称不一样,所以只是贴出来了一份。

public class FromBean {
    private String name;
    private int age;
    private String address;
    private String idno;
    private double money;
 
    public double getMoney() {
        return money;
    }
 
    public void setMoney(double money) {
        this.money = money;
    }
 
    public String getName() {
        return name;
    }
 
    public void setName(String name) {
        this.name = name;
    }
 
    public int getAge() {
        return age;
    }
 
    public void setAge(int age) {
        this.age = age;
    }
 
    public String getAddress() {
        return address;
    }
 
    public void setAddress(String address) {
        this.address = address;
    }
 
    public String getIdno() {
        return idno;
    }
 
    public void setIdno(String idno) {
        this.idno = idno;
    }
 
}

    一个用于测试的BenchmarkTest类,为了减少重复代码,写了一个策略模式

public class BenchmarkTest {    
    private int count;    
    public BenchmarkTest(int count) {        
        this.count = count;
        System.out.println("性能测试" + this.count + "==================");
    }    
    public void benchmark(IMethodCallBack m, FromBean frombean) {        
        try {            
            long begin = new java.util.Date().getTime();
            ToBean tobean = null;
            System.out.println(m.getMethodName() + "开始进行测试");            
            for (int i = 0; i < count; i++) {

                tobean = m.callMethod(frombean);

            }           
            long end = new java.util.Date().getTime();
            System.out.println(m.getMethodName() + "耗时" + (end - begin));
            System.out.println(tobean.getAddress());
            System.out.println(tobean.getAge());
            System.out.println(tobean.getIdno());
            System.out.println(tobean.getMoney());
            System.out.println(tobean.getName());
            System.out.println("                                      ");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

 策略中使用的接口声明

public interface IMethodCallBack {

    String getMethodName();

    ToBean callMethod(FromBean frombean)  throws Exception;

}

使用的测试类

public class TestMain {    
    /**
     * @param args     
     */
    public static void main(String[] args) {
        FromBean fb = new FromBean();
        fb.setAddress("北京市朝阳区大屯路");
        fb.setAge(20);
        fb.setMoney(30000.111);
        fb.setIdno("110330219879208733");
        fb.setName("测试");

        IMethodCallBack beanutilCB = new IMethodCallBack() {

            @Override            
            public String getMethodName() {                
                return "BeanUtil.copyProperties";
            }

            @Override            
            public ToBean callMethod(FromBean frombean) throws Exception {

                ToBean toBean = new ToBean();
                BeanUtils.copyProperties(toBean, frombean);                
                return toBean;
            }
        };

        IMethodCallBack propertyCB = new IMethodCallBack() {

            @Override            
            public String getMethodName() {                
                return "PropertyUtils.copyProperties";
            }

            @Override            
            public ToBean callMethod(FromBean frombean) throws Exception {
                ToBean toBean = new ToBean();
                PropertyUtils.copyProperties(toBean, frombean);                
                return toBean;
            }
        };

        IMethodCallBack springCB = new IMethodCallBack() {

            @Override            
            public String getMethodName() {                
                return "org.springframework.beans.BeanUtils.copyProperties";
            }

            @Override            
            public ToBean callMethod(FromBean frombean) throws Exception {
                ToBean toBean = new ToBean();
                org.springframework.beans.BeanUtils.copyProperties(frombean, toBean);                
                return toBean;
            }
        };

        IMethodCallBack cglibCB = new IMethodCallBack() {
            BeanCopier bc = BeanCopier.create(FromBean.class, ToBean.class, false);

            @Override            
            public String getMethodName() {                
                return "BeanCopier.create";
            }

            @Override            
            public ToBean callMethod(FromBean frombean) throws Exception {
                ToBean toBean = new ToBean();
                bc.copy(frombean, toBean, null);                
                return toBean;
            }
        };
        // 数量较少的时候,测试性能
        BenchmarkTest bt = new BenchmarkTest(10);
        bt.benchmark(beanutilCB, fb);
        bt.benchmark(propertyCB, fb);
        bt.benchmark(springCB, fb);
        bt.benchmark(cglibCB, fb);
        // 测试一万次性能测试
        BenchmarkTest bt10000 = new BenchmarkTest(10000);
        bt10000.benchmark(beanutilCB, fb);
        bt10000.benchmark(propertyCB, fb);
        bt10000.benchmark(springCB, fb);
        bt10000.benchmark(cglibCB, fb);
        // 担心因为顺序问题影响测试结果
        BenchmarkTest bt1000R = new BenchmarkTest(10000);
        bt1000R.benchmark(cglibCB, fb);
        bt1000R.benchmark(springCB, fb);
        bt1000R.benchmark(propertyCB, fb);
        bt1000R.benchmark(beanutilCB, fb);

    }
}

 进行了三次测试,最后的结果如下:

10次测验 第一次 第二次 第三次 平均值 每次平均值
BeanUtil.copyProperties 54 57 50 53.66667 5.366666667
PropertyUtils.copyProperties 4 4 4 4 0.4
org.springframework.beans.BeanUtils.copyProperties 12 10 11 11 1.1
BeanCopier.create 0 0 0 0 0

 

10000次测验 第一次 第二次 第三次 平均值 每次平均值
BeanUtil.copyProperties 241 222 226 229.6667 0.022966667
PropertyUtils.copyProperties 92 90 92 91.33333 0.009133333
org.springframework.beans.BeanUtils.copyProperties 29 30 32 30.33333 0.003033333
BeanCopier.create 1 1 1 1 0.1

 

10000次反转测验 第一次 第二次 第三次 平均值 每次平均值
BeanUtil.copyProperties 178 174 178 176.6667 0.017666667
PropertyUtils.copyProperties 91 87 89 89 0.0089
org.springframework.beans.BeanUtils.copyProperties 21 21 21 21 0.0021
BeanCopier.create 0 1 1 0.666667 6.66667E-05

 

      不过需要注意的是,Cglib在测试的时候,先进行了实例的缓存,这个也是他性能较好的原因之一。如果把缓存去掉的话,性能就会出现了一些的差异,但是整体的性能还是很好,不过奇怪的是10000次反而比10次少,而且后面的反转1万次反而耗时最少,进行多次测试效果也是如此。    从整体的表现来看,Cglib的BeanCopier的性能是最好的无论是数量较大的1万次的测试,还是数量较少10次,几乎都是趋近与零损耗,Spring是在次数增多的情况下,性能较好,在数据较少的时候,性能比PropertyUtils的性能差一些。PropertyUtils的性能相对稳定,表现是呈现线性增长的趋势。而Apache的BeanUtil的性能最差,无论是单次Copy还是大数量的多次Copy性能都不是很好。


10次 10000次 10000次反转
BeanCopier.create 41 28 10

      性能测试就到这里,数据也展示如上,后续会继续编写剩余两篇文章,这一片关注性能,后面的一篇是就每种方式的使用上的差异进行详解,最后一篇想进行探讨是什么早就了这四种方式的性能差异


Bean 复制的几种框架性能比较(Apache BeanUtils、PropertyUtils,Spring BeanUtils,Cglib BeanCopier

Bean 复制的几种框架性能比较(Apache BeanUtils、PropertyUtils,Spring BeanUtils,Cglib BeanCopier

高春辉、王春生、朱峰:关于开源创业的 15 件小事
Bean 复制的几种框架性能比较(Apache BeanUtils、PropertyUtils,Spring BeanUtils,Cglib BeanCopier 博客分类: java
复制代码

 

使用的测试类

复制代码
public class TestMain {

    /**
     * @param args
     */
    public static void main(String[] args) {
        FromBean fb = new FromBean();
        fb.setAddress("北京市朝阳区大屯路");
        fb.setAge(20);
        fb.setMoney(30000.111);
        fb.setIdno("110330219879208733");
        fb.setName("测试");

        IMethodCallBack beanutilCB = new IMethodCallBack() {

            @Override
            public String getMethodName() {
                return "BeanUtil.copyProperties";
            }

            @Override
            public ToBean callMethod(FromBean frombean) throws Exception {

                ToBean toBean = new ToBean();
                BeanUtils.copyProperties(toBean, frombean);
                return toBean;
            }
        };

        IMethodCallBack propertyCB = new IMethodCallBack() {

            @Override
            public String getMethodName() {
                return "PropertyUtils.copyProperties";
            }

            @Override
            public ToBean callMethod(FromBean frombean) throws Exception {
                ToBean toBean = new ToBean();
                PropertyUtils.copyProperties(toBean, frombean);
                return toBean;
            }
        };

        IMethodCallBack springCB = new IMethodCallBack() {

            @Override
            public String getMethodName() {
                return "org.springframework.beans.BeanUtils.copyProperties";
            }

            @Override
            public ToBean callMethod(FromBean frombean) throws Exception {
                ToBean toBean = new ToBean();
                org.springframework.beans.BeanUtils.copyProperties(frombean,
                        toBean);
                return toBean;
            }
        };

        IMethodCallBack cglibCB = new IMethodCallBack() {
            BeanCopier bc = BeanCopier.create(FromBean.class, ToBean.class,
                    false);

            @Override
            public String getMethodName() {
                return "BeanCopier.create";
            }

            @Override
            public ToBean callMethod(FromBean frombean) throws Exception {
                ToBean toBean = new ToBean();
                bc.copy(frombean, toBean, null);
                return toBean;
            }
        };

        // 数量较少的时候,测试性能
        BenchmarkTest bt = new BenchmarkTest(10);
        bt.benchmark(beanutilCB, fb);
        bt.benchmark(propertyCB, fb);
        bt.benchmark(springCB, fb);
        bt.benchmark(cglibCB, fb);

        // 测试一万次性能测试
        BenchmarkTest bt10000 = new BenchmarkTest(10000);
        bt10000.benchmark(beanutilCB, fb);
        bt10000.benchmark(propertyCB, fb);
        bt10000.benchmark(springCB, fb);
        bt10000.benchmark(cglibCB, fb);

        // 担心因为顺序问题影响测试结果
        BenchmarkTest bt1000R = new BenchmarkTest(10000);
        bt1000R.benchmark(cglibCB, fb);
        bt1000R.benchmark(springCB, fb);
        bt1000R.benchmark(propertyCB, fb);
        bt1000R.benchmark(beanutilCB, fb);

    }

}
复制代码

 

 进行了三次测试,最后的结果如下:

10 次测验 第一次 第二次 第三次 平均值 每次平均值
BeanUtil.copyProperties 54 57 50 53.66667 5.366666667
PropertyUtils.copyProperties 4 4 4 4 0.4
org.springframework.beans.BeanUtils.copyProperties 12 10 11 11 1.1
BeanCopier.create 0 0 0 0 0

 

10000 次测验 第一次 第二次 第三次 平均值 每次平均值
BeanUtil.copyProperties 241 222 226 229.6667 0.022966667
PropertyUtils.copyProperties 92 90 92 91.33333 0.009133333
org.springframework.beans.BeanUtils.copyProperties 29 30 32 30.33333 0.003033333
BeanCopier.create 1 1 1 1 0.1

 

10000 次反转测验 第一次 第二次 第三次 平均值 每次平均值
BeanUtil.copyProperties 178 174 178 176.6667 0.017666667
PropertyUtils.copyProperties 91 87 89 89 0.0089
org.springframework.beans.BeanUtils.copyProperties 21 21 21 21 0.0021
BeanCopier.create 0 1 1 0.666667 6.66667E-05

 

      不过需要注意的是,Cglib 在测试的时候,先进行了实例的缓存,这个也是他性能较好的原因之一。如果把缓存去掉的话,性能就会出现了一些的差异,但是整体的性能还是很好,不过奇怪的是 10000 次反而比 10 次少,而且后面的反转 1 万次反而耗时最少,进行多次测试效果也是如此。    从整体的表现来看,Cglib 的 BeanCopier 的性能是最好的无论是数量较大的 1 万次的测试,还是数量较少 10 次,几乎都是趋近与零损耗,Spring 是在次数增多的情况下,性能较好,在数据较少的时候,性能比 PropertyUtils 的性能差一些。PropertyUtils 的性能相对稳定,表现是呈现线性增长的趋势。而 Apache 的 BeanUtil 的性能最差,无论是单次 Copy 还是大数量的多次 Copy 性能都不是很好。

  10 次 10000 次 10000 次反转
BeanCopier.create 41 28 10

      性能测试就到这里,数据也展示如上,后续会继续编写剩余两篇文章,这一片关注性能,后面的一篇是就每种方式的使用上的差异进行详解,最后一篇想进行探讨是什么早就了这四种方式的性能差异。

 

 

http://www.cnblogs.com/kaka/archive/2013/03/06/2945514.html

ch.qos.logback.core.status.StatusUtil的实例源码

ch.qos.logback.core.status.StatusUtil的实例源码

项目:konker-platform    文件:KonkerStaticLoggerBinder.java   
void init() {
    try {
        try {
            (new KonkerContextinitializer(this.defaultLoggerContext)).autoConfig();
        } catch (JoranException var2) {
            Util.report("Failed to auto configure default logger context",var2);
        }

        if(!StatusUtil.contextHasstatusListener(this.defaultLoggerContext)) {
            StatusPrinter.printInCaSEOfErrorsOrWarnings(this.defaultLoggerContext);
        }

        this.contextSelectorBinder.init(this.defaultLoggerContext,KEY);
        this.initialized = true;
    } catch (Throwable var3) {
        Util.report("Failed to instantiate [" + LoggerContext.class.getName() + "]",var3);
    }

}
项目:bartleby    文件:GenericConfigurator.java   
public final void doConfigure(final InputSource inputSource)
        throws JoranException {

  long threshold = System.currentTimeMillis();
  if (!ConfigurationWatchListUtil.wasConfigurationWatchListReset(context)) {
    informContextOfURLUsedForConfiguration(getContext(),null);
  }
  SaxEventRecorder recorder = new SaxEventRecorder(context);
  recorder.recordEvents(inputSource);
  doConfigure(recorder.saxEventList);
  // no exceptions a this level
  StatusUtil statusUtil = new StatusUtil(context);
  if (statusUtil.noXMLParsingErrorsOccurred(threshold)) {
    addInfo("Registering current configuration as safe fallback point");
    registerSafeConfiguration();
  }
}
项目:bartleby    文件:StaticLoggerBinder.java   
/**
 * Package access for testing purposes.
 */
void init() {
  try {
    try {
      new Contextinitializer(defaultLoggerContext).autoConfig();
    } catch (JoranException je) {
      Util.report("Failed to auto configure default logger context",je);
    }
    // logback-292
    if(!StatusUtil.contextHasstatusListener(defaultLoggerContext)) {
      StatusPrinter.printInCaSEOfErrorsOrWarnings(defaultLoggerContext);
    }
    contextSelectorBinder.init(defaultLoggerContext,KEY);
    initialized = true;
  } catch (Throwable t) {
    // we should never get here
    Util.report("Failed to instantiate [" + LoggerContext.class.getName()
        + "]",t);
  }
}
项目:bartleby    文件:ReconfigureOnChangeFilter.java   
private void performXMLConfiguration(LoggerContext lc) {
  JoranConfigurator jc = new JoranConfigurator();
  jc.setContext(context);
  StatusUtil statusUtil = new StatusUtil(context);
  List<SaxEvent> eventList = jc.recallSafeConfiguration();
  URL mainURL = ConfigurationWatchListUtil.getMainWatchURL(context);
  lc.reset();
  long threshold = System.currentTimeMillis();
  try {
    jc.doConfigure(mainConfigurationURL);
    if (statusUtil.hasXMLParsingErrors(threshold)) {
      fallbackConfiguration(lc,eventList,mainURL);
    }
  } catch (JoranException e) {
    fallbackConfiguration(lc,mainURL);
  }
}
项目:common-libraries    文件:ImprovedAuditorFactory.java   
public static int getHighestLevel(long threshold,StatusManager sm ) {
    List filteredList = StatusUtil.filterStatusListByTimeThreshold(sm.getcopyOfStatusList(),threshold);
    int maxLevel = 0;
    Iterator i$ = filteredList.iterator();

    while(i$.hasNext()) {
        Status s = (Status)i$.next();
        if(s.getLevel() > maxLevel) {
            maxLevel = s.getLevel();
        }
    }

    return maxLevel;
}
项目:bartleby    文件:MBeanUtil.java   
public static void createAndRegisterJMXConfigurator(
    MBeanServer mbs,LoggerContext loggerContext,JMXConfigurator jmxConfigurator,ObjectName objectName,Object caller) {
  try {
    mbs.registerMBean(jmxConfigurator,objectName);
  } catch (Exception e) {
    StatusUtil statusUtil = new StatusUtil(loggerContext);
    statusUtil.addError(caller,"Failed to create mbean",e);
  }
}
项目:bartleby    文件:ContextJNdiselector.java   
public LoggerContext getLoggerContext() {
  String contextName = null;
  Context ctx = null;

  // First check if ThreadLocal has been set already
  LoggerContext lc = threadLocal.get();
  if (lc != null) {
    return lc;
  }

  try {
    // We first try to find the name of our
    // environment's LoggerContext
    ctx = JNDIUtil.getinitialContext();
    contextName = (String) JNDIUtil.lookup(ctx,JNDI_CONTEXT_NAME);
  } catch (NamingException ne) {
    // We can't log here
  }

  if (contextName == null) {
    // We return the default context
    return defaultContext;
  } else {
    // Let's see if we already kNow such a context
    LoggerContext loggerContext = synchronizedContextMap.get(contextName);

    if (loggerContext == null) {
      // We have to create a new LoggerContext
      loggerContext = new LoggerContext();
      loggerContext.setName(contextName);
      synchronizedContextMap.put(contextName,loggerContext);
      URL url = findConfigFileURL(ctx,loggerContext);
      if (url != null) {
        configureLoggerContextByURL(loggerContext,url);
      } else {
        try {
          new Contextinitializer(loggerContext).autoConfig();
        } catch (JoranException je) {
        }
      }
      // logback-292
      if (!StatusUtil.contextHasstatusListener(loggerContext))
        StatusPrinter.printInCaSEOfErrorsOrWarnings(loggerContext);
    }
    return loggerContext;
  }
}
项目:sdcct    文件:LoggingInitializerRunListener.java   
@Override
@SuppressWarnings({ CompilerWarnings.UNCHECKED })
public void environmentPrepared(ConfigurableEnvironment env) {
    this.buildInitializer(DefaultLoggingInitializer::new).initialize(env);

    this.loggerContext = ContextSelectorStaticBinder.getSingleton().getContextSelector().getDefaultLoggerContext();

    SLF4JBridgeHandler.removeHandlersForRootLogger();
    SLF4JBridgeHandler.install();

    this.loggerContext.stop();
    this.loggerContext.reset();

    LevelChangePropagator lvlChangePropagator = new LevelChangePropagator();
    lvlChangePropagator.setContext(this.loggerContext);
    lvlChangePropagator.setResetJUL(true);
    this.loggerContext.addListener(lvlChangePropagator);

    this.loggerContext.putObject(SdcctApplication.BEAN_NAME,this.app);

    this.buildConversionRule(MessageMarkerConverter.WORD,MessageMarkerConverter.class);
    this.buildConversionRule(PriorityColorCompositeConverter.WORD,PriorityColorCompositeConverter.class);
    this.buildConversionRule(RootCauseThrowableProxyConverter.WORD,RootCauseThrowableProxyConverter.class);
    this.buildConversionRule(ThreadSectionConverter.WORD,ThreadSectionConverter.class);
    this.buildConversionRule(TxMdcConverter.WORD,TxMdcConverter.class);

    this.buildAppender(new ConsoleAppender<>(),AppenderType.CONSOLE,this.buildPatternLayoutEncoder(CONSOLE_APPENDER_PATTERN),true);

    this.buildFileAppender(AppenderType.FILE,this.buildPatternLayoutEncoder(FILE_APPENDER_PATTERN),new File(
        (this.logFileDir = this.app.getLogFileDirectory()),(this.app.getLogFileName() + FilenameUtils.EXTENSION_SEParaTOR + SdcctFileNameExtensions.LOG)));

    this.buildCachingAppender(AppenderType.LOGSTASH_FILE);

    this.buildLogger(org.slf4j.Logger.ROOT_LOGGER_NAME,Level.WARN,true,this.appenders.values());

    PropertySourceUtils.getSubProperties(env.getPropertySources(),SdcctPropertyNames.LOGGING_LOGGER_PREFIX).forEach((loggerName,loggerPropValue) -> {
        String[] loggerPropValueParts = StringUtils.split(((String) loggerPropValue),SdcctStringUtils.COLON,2);
        Level loggerLvl = Level.toLevel(loggerPropValueParts[0].toupperCase(),null);

        if (loggerLvl == null) {
            throw new ApplicationContextException(
                String.format("UnkNown application (name=%s) logger (name=%s) level: %s",this.app.getName(),loggerName,loggerPropValueParts[0]));
        }

        this.buildLogger(loggerName,loggerLvl,false,((loggerPropValueParts.length == 2)
            ? Stream.of(org.springframework.util.StringUtils.commaDelimitedListToStringArray(loggerPropValueParts[1])).map(loggerAppenderName -> {
                AppenderType loggerAppenderType = SdcctEnumUtils.findById(AppenderType.class,loggerAppenderName);

                if (!this.appenders.containsKey(loggerAppenderType)) {
                    throw new ApplicationContextException(String.format("UnkNown application (name=%s) logger (name=%s) appender type (name=%s).",loggerAppenderName));
                }

                return this.appenders.get(loggerAppenderType);
            }).collect(Collectors.toList()) : this.appenders.values()));
    });

    StatusManager statusManager = this.loggerContext.getStatusManager();
    StatusUtil statusUtil = new StatusUtil(statusManager);
    long lastResetTime = statusUtil.timeOfLastReset();

    if (statusUtil.getHighestLevel(lastResetTime) >= Status.WARN) {
        StatusPrinter.print(statusManager,lastResetTime);

        throw new ApplicationContextException(String.format("Unable to initialize application (name=%s) logging.",this.app.getName()));
    }

    this.loggerContext.getLogger(LoggingInitializerRunListener.class).info(String.format("Application (name=%s) logging initialized.",this.app.getName()));
}
项目:crigtt    文件:LoggingApplicationRunListener.java   
@Override
public void started() {
    SLF4JBridgeHandler.removeHandlersForRootLogger();
    SLF4JBridgeHandler.install();

    this.app.addListeners(this);

    LoggerContext loggerContext = ContextSelectorStaticBinder.getSingleton().getContextSelector().getLoggerContext();

    loggerContext.stop();
    loggerContext.reset();

    String appName = this.app.getName(),consoleTty = System.getProperty(CrigttProperties.LOGGING_CONSOLE_TTY_NAME);
    CrigttLoggingInitializer loggingInit = buildComponent(CrigttLoggingInitializer.class,DefaultLoggingInitializer::new,this.app);

    loggerContext.setName(appName);
    loggerContext
        .putProperty(CrigttProperties.LOGGING_CONSOLE_TTY_NAME,((consoleTty != null) ? consoleTty : Boolean.toString((System.console() != null))));
    loggerContext.putProperty(CrigttProperties.LOGGING_FILE_DIR_NAME,loggingInit.buildLogDirectory().getPath());
    loggerContext.putProperty(CrigttProperties.LOGGING_FILE_NAME_NAME,loggingInit.buildLogFileName());

    String configFileUrlPath = LOGBACK_CONfig_FILE_URL_PATH_PREFIX + appName + FilenameUtils.EXTENSION_SEParaTOR + CrigttFileExtensions.GROOVY;
    URL configFileUrl;

    try {
        GafferConfigurator configurator = new GafferConfigurator(loggerContext);

        loggerContext.putObject(ClassicConstants.GAFFER_CONfigURATOR_FQCN,configurator);

        configurator.run(IoUtils.toString((configFileUrl = ResourceUtils.getURL(configFileUrlPath))));
    } catch (IOException e) {
        throw new ApplicationContextException(String.format("Unable to process Logback configuration file (path=%s).",configFileUrlPath),e);
    }

    StatusManager statusManager = loggerContext.getStatusManager();
    StatusUtil statusUtil = new StatusUtil(statusManager);
    long lastResetTime = statusUtil.timeOfLastReset();

    if (statusUtil.getHighestLevel(lastResetTime) >= Status.WARN) {
        StatusPrinter.print(statusManager,lastResetTime);

        throw new ApplicationContextException(String.format("Unable to initialize Logback using configuration file (path=%s).",configFileUrlPath));
    }

    loggingInit.postProcessContext(loggerContext);

    loggerContext.getLogger(LoggingApplicationRunListener.class).info(
        String.format("Logging initialized (initializerClass=%s,configFileUrl=%s).",loggingInit.getClass().getName(),configFileUrl.toString()));
}

今天关于macos – Binutils stat非法选项-c的讲解已经结束,谢谢您的阅读,如果想了解更多关于activerecord – Rails 4.1枚举:enum.status = nil、Apache的BeanUtils和PropertyUtils,Spring的BeanUtils,Cg、Bean 复制的几种框架性能比较(Apache BeanUtils、PropertyUtils,Spring BeanUtils,Cglib BeanCopier、ch.qos.logback.core.status.StatusUtil的实例源码的相关知识,请在本站搜索。

本文标签: