Dynamic file name in log4j’s file appender

In your log4j.xml, set the file name as a variable <appender name=”my-file-appender” class=”org.apache.log4j.FileAppender”> <param name=”file” value=”${myFilePath}” /> <!– … –> </appender> Then in your java code, make sure the following is called before the first getLogger() call System.setProperty(“myFilePath”, someFilePath);

Quick log4j set up

<!– pom.xml –> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.7.7</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.7.7</version> </dependency> <!– src/main/resources/log4j.xml –> <?xml version=”1.0″ encoding=”UTF-8″?> <!DOCTYPE log4j:configuration SYSTEM “log4j.dtd”> <log4j:configuration xmlns:log4j=”http://jakarta.apache.org/log4j/”> <appender name=”my-file-appender” class=”org.apache.log4j.FileAppender”> <param name=”file” value=”some.file” /> <param name=”append” value=”true” /> <param name=”encoding” value=”UTF-8″ /> <layout class=”org.apache.log4j.PatternLayout”> <param name=”ConversionPattern” value=”%d %t %-5p %c – %m%n” /> </layout> </appender> <appender name=”console” …

Quick log4j set up Read More »

Basic Redux Counter example

In this example, The "CounterComponet" is included by the root component called "AppComponent". No Store composition is used here. You still have to pass the props to "AppComponent", which in turn passes them to "CounterComponent" So it will not demonstrate how good Redux is, but will just let you know the basic ideas of Redux. …

Basic Redux Counter example Read More »

Frontend frameworks and things you should know in addition to React/Angular

Language ES2015: A new generation of Javascript language specs. It supports modules and classes. It’s also know as ES6 Typescript: An object-oriented language that will be converted to Javascript and then be run in browsers Babel: make code run in an browser that doesn’t support this code, for example running ES6+ in current browsers, or …

Frontend frameworks and things you should know in addition to React/Angular Read More »

How to prevent Quartz from re-firing a job while it is still running

Answer: use @DisallowConcurrentExecution Example Without this annotation import java.time.LocalTime; import org.quartz.DisallowConcurrentExecution; import org.quartz.Job; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; public class HelloJob implements Job { @Override public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { System.out.println(Thread.currentThread().getName() + “:Job started at ” + LocalTime.now()); try { Thread.sleep(10 * 1000); } catch (InterruptedException e) { throw new RuntimeException(e); } System.out.println(Thread.currentThread().getName() + …

How to prevent Quartz from re-firing a job while it is still running Read More »

Quartz concepts

Basic concepts Job: What to do Trigger: When to do it Scheduler: The director to associate triggers to jobs and to invoke the trigger A job can be associated with several triggers, but a trigger should not be used to trigger more than one job Go into details for some depth JobKey = Job Name …

Quartz concepts Read More »

Forwarded servlet request won’t be intercepted by filters

The new request created by RequestDispatcher.forward(request, response) will not be intercepted by its matching filters defined in web.xml To make a filter work for requests created by dispatcher, you have to add 2 dispatcher configurations to your filter mapping someFilter /* REQUEST FORWARD

Import a merge commit from on branch to another branch

git diff the-commit-before-your-commit your-commit > abc.diff git apply –reject –whitespace=fix abc.diff #If you not lucky, you will see some *.rej files generated, which mean failed patchings #You can still a tool to called “wiggle” deal with them wget http://neil.brown.name/wiggle/wiggle-1.1.tar.gz tar xvf wiggle-1.1.tar.gz # You may have to install ncurses library first sudo yum search ncurses …

Import a merge commit from on branch to another branch Read More »