Note that there are some explanatory texts on larger screens.

plurals
  1. POderby.log (etc) control in a webapp
    text
    copied!<p>Derby has a series of configuration options that are controlled by system properties. It's quite painful to arrange system property settings in a webapp. Has anyone come up with a solution?</p> <p>In addition, I have been unable to make them work in a webapp.</p> <p>Here is the code of a servlet context listener. derby.log is still created in the cwd of the container, rather than calls being made to my logging procedure.</p> <pre><code>/** * 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"); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload