Skip to content

Commit

Permalink
Added log config and port config from the command line
Browse files Browse the repository at this point in the history
  • Loading branch information
afisk committed Oct 25, 2009
1 parent ee92167 commit 1912a23
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/main/java/org/littleshoot/proxy/HttpProxyServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,20 @@ public static void main(final String[] args) {
Executors.newCachedThreadPool()));

bootstrap.setPipelineFactory(new HttpServerPipelineFactory());
bootstrap.bind(new InetSocketAddress("127.0.0.1", 8080));

final int defaultPort = 8080;
int port;
if (args.length > 0) {
final String arg = args[0];
try {
port = Integer.parseInt(arg);
} catch (final NumberFormatException e) {
port = defaultPort;
}
} else {
port = defaultPort;
}
bootstrap.bind(new InetSocketAddress("127.0.0.1", port));

/*
final ServerBootstrap sslBootstrap = new ServerBootstrap(
Expand Down
31 changes: 31 additions & 0 deletions src/main/resources/log4j.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Set the root loggers
log4j.rootLogger=warn, stdout, TextFile


# The root logger uses the appenders called stdout, TextFile and XMLFile.
# The default level for these loggers is OFF.

# stdout is set to be ConsoleAppender sending its output to System.out
log4j.appender.stdout=org.apache.log4j.ConsoleAppender

# stdout uses PatternLayout.
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout

# TextFile uses PatternLayout as well
log4j.appender.RollingTextFile=org.apache.log4j.RollingFileAppender
log4j.appender.RollingTextFile.File=log.txt
log4j.appender.RollingTextFile.MaxFileSize=50MB
log4j.appender.RollingTextFile.MaxBackupIndex=5
log4j.appender.RollingTextFile.layout=org.apache.log4j.PatternLayout

log4j.appender.TextFile=org.apache.log4j.FileAppender
log4j.appender.TextFile.File=log.txt
log4j.appender.TextFile.Append=false
log4j.appender.TextFile.layout=org.apache.log4j.PatternLayout

log4j.appender.stdout.layout.ConversionPattern=%-6r %d{ISO8601} %-5p [%t] %c{2}.%M (%F:%L) - %m%n
log4j.appender.TextFile.layout.ConversionPattern=%-6r %d{ISO8601} %-5p [%t] %c{2}.%M (%F:%L) - %m%n

log4j.logger.httpclient.wire=off
org.apache.commons=off
log4j.logger.org.littleshoot.proxy=all

0 comments on commit 1912a23

Please sign in to comment.