小编Qbi*_*iek的帖子

Log4j2配置 - 找不到log4j2配置文件

最近我决定学习如何使用log4j2记录器.我下载了所需的jar文件,创建了库,xml配置文件,并尝试使用它.不幸的是我在控制台(Eclipse)中得到了这个声明:

ERROR StatusLogger No log4j2 configuration file found. Using default configuration:       logging only errors to the console.
Run Code Online (Sandbox Code Playgroud)

这是我的测试类代码:

package log4j.test;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public class Log4jTest
{
    static final Logger logger = LogManager.getLogger(Logger.class.getName());

    public static void main(String[] args) {    
        logger.trace("trace");
        logger.debug("debug");
        logger.info("info");
        logger.warn("warn");
        logger.error("error");
        logger.fatal("fatal");
    }
}
Run Code Online (Sandbox Code Playgroud)

和我的xml配置文件:

<?xml version="1.0" encoding="UTF-8"?>
<Configuration package="log4j.test" 
               status="WARN">
    <Appenders>
        <Console name="Console" target="SYSTEM_OUT">
            <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
        </Console>
    </Appenders>
    <Loggers>
        <Logger name="log4j.test.Log4jTest" level="trace">
            <AppenderRef ref="Console"/>
        </Logger>
        <Root level="trace">
            <AppenderRef ref="Console"/>
        </Root> …
Run Code Online (Sandbox Code Playgroud)

java logging log4j2

85
推荐指数
3
解决办法
15万
查看次数

如何在javaFX中创建左,中,右部分的工具栏?

我正在尝试在javafx中创建自定义工具栏.此工具栏应该能够在其表面的中心,左侧和右侧(三个部分)显示控件.问题是我不知道这个.我读了很多与这个问题相关的提示,但是他们不适合我,或者我做错了什么......

无论如何,我写了几个方法,它们代表了实现我的工具栏的不同方法,但没有一个正常工作.在这里你有我的尝试:

  1. 使用HBox Hgrow属性作为弹簧.没工作.

    public ToolBar createToolBar()
    {
        ToolBar toolBar = new ToolBar();
        Pane emptyPane = new Pane();
        HBox spring = new HBox(emptyPane);
        spring.setHgrow(emptyPane, Priority.ALWAYS);
        toolBar.getItems().addAll(spring, new Label("LABEL"));
        return toolBar;
    }
    
    Run Code Online (Sandbox Code Playgroud)

2.它适用于左右两部分,但如何定义中心部分?

    public AnchorPane createToolBar2()
    {
        AnchorPane toolBar = new AnchorPane();
        Label leftLabel = new Label("left");
        Label rightLabel = new Label("right");
        toolBar.getChildren().addAll(leftLabel, rightLabel);
        toolBar.setLeftAnchor(leftLabel, 0.0);
        toolBar.setRightAnchor(rightLabel, 0.0);
        return toolBar;
    }
Run Code Online (Sandbox Code Playgroud)
  1. 这种方法适用于布局,但我无法监听左侧和中间部分的事件,因为这些事件由右侧部分覆盖(StackPane是原因),因此该解决方案也没用.

    public StackPane createToolBar3()
    {
        StackPane toolBar = new StackPane();
        Button left = new Button("left button");
        Button right = new …
    Run Code Online (Sandbox Code Playgroud)

java javafx toolbar alignment

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

java ×2

alignment ×1

javafx ×1

log4j2 ×1

logging ×1

toolbar ×1