Web applications webapp中的derby.log(etc)控件

Web applications webapp中的derby.log(etc)控件,web-applications,derby,Web Applications,Derby,Derby有一系列由系统属性控制的配置选项。在webapp中安排系统属性设置是非常痛苦的。有人想出解决办法了吗 此外,我无法让它们在网络应用程序中工作 下面是servlet上下文侦听器的代码。仍然在容器的cwd中创建derby.log,而不是调用我的日志过程 /** * Listener to try to get Derby to behave better. */ public class ContextListener implements ServletContextListener

Derby有一系列由系统属性控制的配置选项。在webapp中安排系统属性设置是非常痛苦的。有人想出解决办法了吗

此外,我无法让它们在网络应用程序中工作

下面是servlet上下文侦听器的代码。仍然在容器的cwd中创建derby.log,而不是调用我的日志过程

/**
 * Listener to try to get Derby to behave better.
 */
public class ContextListener implements ServletContextListener {

    private static final String TEMP_DIR_ATTRIBUTE = "javax.servlet.context.tempdir";
    private static ServletContext context;
    private static Writer logWriter;

    private class LogWriter extends Writer {

        @Override
        public void close() throws IOException {
        }

        @Override
        public void flush() throws IOException {
        }

        @Override
        public void write(char[] cbuf, int off, int len) throws IOException {
            context.log(new String(cbuf, off, len));
        }

    }

    /** {@inheritDoc}*/
    public void contextDestroyed(ServletContextEvent sce) {
    }

    public static Writer getLogSteam() {
        return logWriter;
    }

    /** {@inheritDoc}*/
    public void contextInitialized(ServletContextEvent sce) {
        logWriter = new LogWriter();
        File tempDirFile = (File)sce.getServletContext().getAttribute(TEMP_DIR_ATTRIBUTE);
        context = sce.getServletContext();
        System.setProperty("derby.system.home", tempDirFile.getAbsolutePath());
        System.setProperty("derby.stream.error.method", "com.basistech.vws.ContextListener.getLogStream");
    }

}

有多种方法可以设置Derby属性。这里有一些文档:你没有说这其中的哪一部分是痛苦的,所以很难知道你在寻找什么样的解决方案


您正试图设置哪些属性,设置这些属性的哪一个方面令人痛苦?

我不想告诉客户/用户,他们必须在tomcat/whatever的发布中添加系统属性。似乎缺少的是在类路径中放置某些内容的能力。如果我错过了什么,请告诉我。我已经看完了那个文档。好吧,根据您正试图设置的属性以及应用程序的设置方式,这里有一些其他技术:首先,您可以将derby.properties文件放入您用作derby主页的位置。第二,在加载Derby JDBC驱动程序之前,您可以自己调用System.setProperty()。请检查的答案,以获得一些演示System.setProperty技术的实际代码。@Bryan Pendleton,这些在webapps中不太可用。