I had this same desire: to alter the format of the timestamp in log records produced by Log4J's HTMLLayout. After some extensive Googling, it appeared that there were only 3 options:
Re-invent the wheel and write a custom HTMLLayout classExtend the Log4J HTMLLayout class and replace the format() methodModify the source code for the Log4J HTMLLayout class Unfortunately, none of these were very appealing options; all I needed was to change the format of the timestamp!
Then it hit me: there's another option that involves overriding the format() method, but not rewriting it in its entirety. What I decided to do was write a custom HTML layout class and intercept the log record (by overriding the format() method) and use RegEx to locate and replace the timestamp with one having the desired format. And the beauty of it is that the format can be specified externally as a property in the log4j configuration file!
Sample code for my layout class is shown below.