通过logger.log覆盖处理程序级别

时间:2019-05-27 10:03:00

标签: java handler java.util.logging

有没有一种方法可以通过记录器对象覆盖处理程序级别。

例如:

FileHandler logFile = new FileHandler("DefaultLogger.log");
logger.setLevel(Level.FINE);

还应将fileHandler的级别设置为精细。

1 个答案:

答案 0 :(得分:0)

您可以使用Logger::getHandlers方法来获取给定记录器的所有安装处理程序。例如:

autoreleasepool {
    for offset in stride(from: 0.0, through: planeWidth, by: increment) {
        var topLeftTransform = arkitAnchor!.simdWorldTransform * HelperMethods.makeTranslationMatrix(tx: -Float(planeWidth / 2), ty: 0.0, tz: -Float(planeHeight/2))
        topLeftTransform = topLeftTransform * HelperMethods.makeTranslationMatrix(tx: Float(offset), ty: 0.0, tz: 0.0)
        let topEdgePosition = simd_float3(x: topLeftTransform.columns.3.x, y: topLeftTransform.columns.3.y, z: topLeftTransform.columns.3.z)
        saLabelComponent.simdWorldPosition = topEdgePosition

        let oldSpriteTransform = sprite.simdWorldTransform

        for xOffset in stride(from:-0.20, through: 0.20, by: increment) {
            for yOffset in stride(from: 0.05, through: 0.20, by: increment) {
                LOOP_1_ITERATIONS += 1
                var newSpriteTransform = anchor.simdWorldTransform * HelperMethods.makeTranslationMatrix(tx: Float(xOffset), ty: Float(yOffset), tz: 0.0)
                sprite.simdWorldTransform = newSpriteTransform
            }
        }
    }
}

否则,如果要在所有记录器上查找所有处理程序,则可以使用以下命令:

simdWorldPosition