Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/350.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用Log4j,我的应用程序每天生成许多日志文件_Java_Logging_Web Services - Fatal编程技术网

Java 使用Log4j,我的应用程序每天生成许多日志文件

Java 使用Log4j,我的应用程序每天生成许多日志文件,java,logging,web-services,Java,Logging,Web Services,我有一个web服务,我使用的是LOG4J,但每天我的应用程序都会生成许多日志文件,这些文件在几天内就会填满大量内存空间,溢出磁盘容量 我在web.xml上没有属性文件或配置 我有这个: public class OrchestrationDEServices { static Logger log; public OrchestrationDEServices() { BasicConfigurator.configure(); log = Logger.getLogger(

我有一个web服务,我使用的是LOG4J,但每天我的应用程序都会生成许多日志文件,这些文件在几天内就会填满大量内存空间,溢出磁盘容量

我在web.xml上没有属性文件或配置

我有这个:

public class OrchestrationDEServices {

static Logger log;

public OrchestrationDEServices() {
    BasicConfigurator.configure();
    log = Logger.getLogger(Thread.currentThread().getStackTrace()[1].getClassName() + ".class");
}

public static boolean isNumeric(String strNum) {
    try {
        @SuppressWarnings("unused")
        double d = Double.parseDouble(strNum);
    } catch (NumberFormatException | NullPointerException nfe) {
        return false;
    }
    return true;
}


public static JSONArray ctrlHistAcadByCodigoService(String codigo) {
    JSONArray jArray = null;

    SqlConnection conx = null;
    Connection conn = null;

    if (isNumeric(codigo)) {
        try {
            conx = new SqlConnection();
            conx.Open();
            conn = conx.getConnection();
            jArray = new JSONArray();

            jArray = ResponseDE_Services.histAcadByCodigoRE(conn, codigo);
        } catch (Exception e) {
            log.warn(Thread.currentThread().getStackTrace()[1].getMethodName() + " --> Excepcion Exepcion general", e);
        } finally {

            try {
                if (conn != null) {
                    conn.close();
                }
            } catch (SQLException e) {
                log.warn(Thread.currentThread().getStackTrace()[1].getMethodName() + " --> Se intento cerrar Connection", e);
            }

            try {
                if (conx != null) {
                    conx.Close();
                }
            } catch (Exception e) {
                log.warn(Thread.currentThread().getStackTrace()[1].getMethodName() + " --> Se intento cerrar SqlConnection", e);
            }
        }
    } else {
        log.error(Thread.currentThread().getStackTrace()[1].getMethodName() + " Codigo de estudiante no es tipo entero");
    }

    return jArray;
}
}


请问,对我的麻烦有什么建议吗?

确切的问题是什么?您想让日志占用更少的空间,还是想找出日志记录过于频繁的原因?或者…?我想知道为什么日志记录发生得太频繁?