两个不同记录器的两个文件处理程序获得相同的内容

时间:2017-01-16 14:56:14

标签: python email logging

我编写了一个脚本,从cloudwatch收集事件日志,将它们写入两个文件,然后通过邮件发送每个文件的内容。由于我想收到两封电子邮件,每个记录器都有不同类型的日志,我创建了两个记录器:

function1(arg1,arg2,logger1)
function2(arg1,arg2,logger2)
在主要的,我称这样的函数:

  newconf = {"mapred.input.dir": <<DIRECTORY>>}                        
    hadoopRdd01 = sc.newAPIHadoopRDD("org.apache.hadoop.mapreduce.lib.input.TextInputFormat",
                                "org.apache.hadoop.io.Text",
                                "org.apache.hadoop.io.Text",
                                conf=newconf)

现在,我的问题是,当我执行我的脚本时,我在两个文件处理程序中获得相同的内容,即使我将记录器分开。为什么会这样?

1 个答案:

答案 0 :(得分:1)

这是因为import { ComponentFixture, TestBed } from '@angular/core/testing'; import { By } from '@angular/platform-browser'; import { DebugElement } from '@angular/core'; import { ModalNotaComponent } from '../modal.nota.component'; describe('Test of test variable', () => { let component: ModalNotaComponent; let fixture: ComponentFixture<ModalNotaComponent>; beforeEach(() => { TestBed.compileComponents(); // ModalNotaComponent test instance TestBed.configureTestingModule({ declarations: [ ModalNotaComponent ], // declare the test component }); fixture = TestBed.createComponent(ModalNotaComponent); component = fixture.componentInstance; }); it('Should show that the value of test variable is true', () => { expect(component.test).toBe(true); }); it('Should test setFalse method', () => { let r = null; let t = true; r = component.setFalse(t); expect(r).toBe(false); }); }); logger1都指向下方的 root logger2

来自docsLogger

您需要两个单独的Multiple calls to getLogger() with the same name will always return a reference to the same Logger object.个对象:

Logger