Apache (; ) is the collective term for several culturally related groups of Native Americans in the United States originally from the Southwest United States. [http://en.wikipedia.org/wiki/Apache]
Read more: Ant scripts How to...
Inline linking (also known as hotlinking, leeching, piggy-backing, direct linking, offsite image grabs and bandwidth theft) is the use of a linked object, often an image, from one site into a web page belonging to a second site. The second site is said to have an inline link to the site where the object is located.
This is not just Bandwidth Stealing, as
The mod_rewrite module is able to intercept incoming URLs and modify them according to a set of rules that you specify. The basic idea is use the mod_rewrite module to inspect the incoming HTTP header. The field we're looking for is the Referer field - or basically the URL that the current request originated from.
Referer
This optional header field allows the client to specify, for the server's benefit, the address ( URI ) of the document (or element within the document) from which the URI in the request was obtained.
This allows a server to generate lists of back-links to documents, for interest, logging, etc. It allows bad links to be traced for maintenance.
So create a file .htaccess at the root of your site with the following content:
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?waltercedric.com(/)?.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?wiki.waltercedric.com(/)?.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?forums.waltercedric.com(/)?.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?bugs.waltercedric.com(/)?.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?demo.waltercedric.com(/)?.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?demo2.waltercedric.com(/)?.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mirror.waltercedric.com(/)?.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?images.google.com(/)?.*$ [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp|zip|css)$ http://www.waltercedric.com/bandwidthStealing.html [R,NC]
Notes:
There is a useful online generator with a lot more explanation online at the bottom of this page http://www.htmlbasix.com/disablehotlinking.shtml . This is active on my server since 2 weeks, and I've see a performance in response time.
More tips
![]()
Thanks to Packt Publishing for having sent me this book to review. I will publish a review in the next coming days
You may also consider reading all my articles related to Apache Maven
In computer programming, a unit test is a method of testing the correctness of a particular module of source code. The idea is to write test cases for every non-trivial function or method in the module so that each test case is separate from the others if possible.
![]() | ModSecurityTM is an open source intrusion detection and prevention engine for web applications (or a web application firewall). Operating as an Apache Web server module or standalone, the purpose of ModSecurity is to increase web application security, protecting web applications from known and unknown attacks. from http://www.modsecurity.org/ |
You'll have to create a free account at https://bsn.breach.com to get the real link
# cd
# wget https://bsn.breach.com/downloads/t=5156aa8803d6f186cf38688be522a402/modsecurity-apache/modsecurity-apache_2.5.7.tar.gz
# tar -zxfv modsecurity-apache_2.5.7.tar.gz
# cd modsecurity-apache_2.5.7/apache2
# ./configure
# make
Copy the library mod_security2.so to /usr/lib/apache2
# cp /root/modsecurity-apache_2.5.7/apache2/.libs/mod_security2.so /usr/lib/apache2/mod_security2.so
Then copy all latest rules into apache2/conf.d folder
# cp -r /root/modsecurity-apache_2.5.7/rules/etc/apache2/conf.d/
Copy the minimal configuration file into apache2/conf.d folder
# cp /root/modsecurity-apache_2.5.7/modsecurity.conf-minimal /etc/apache2/conf.d/modsecurity2.conf
Add this line at the top of modsecurity2.conf
LoadModule security2_module /usr/lib/apache2/mod_security2.so
Restart apache2 by executing
# rcapache2 restart
Verify proper operations by looking at log files
# tail -f /var/log/apache2/modsec_debug_log
Attention this is my location for log files!
Change
in /etc/apache2/conf.d/rules/modsecurity_crs_10_config.conf
The Maven Dependency Plugin among other things include a dependency:analyze-duplicate
The dependency plugin provides the capability to manipulate artifacts. It can copy and/or unpack artifacts from local or remote repositories to a specified location.
This Apache Maven plugin is really feature rich and provide a lot of interesting goals:
Read more: List conflicting dependencies in the Maven reactor

Work in progress
A lot of people have tried numerous times to download files from my download section without
success, the error message was always the same
Unrecoverable error "PCLZIP_ERR_BAD_FORMAT (-10)"
Also, Some tried to unpack the zip file locally using stuffit/Winrar/7Zip and get an error suggesting
that the archive is damaged.
Only Internet Explorer users were having issues, this is because of Internet explorer not able to handle
compression of all file types. I solved the issue by changing my mod_deflate.conf which now look like the following:
<Location />
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/x-javascript
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</Location>
I found that I had to use application/x-javascript instead of application/javascript to actually get javascript files on my
server to be served compressed.
mod deflate documentation: http://httpd.apache.org/docs/2.0/mod/mod_deflate.html
![]()
Scenarios
This is where the Maven Enforcer Plugin will assist you:
The Enforcer plugin provides goals to control certain environmental constraints such as Maven version, JDK version and OS family along with many more standard rules and user created rules.
Add in your pom.xml the following to configure the plugin
Read more: Break Maven build when there is a dependency conflict
Log4J: A logging framework for J2EE
Log4j homepage: http://jakarta.apache.org/log4j/
Reference book on log4j:
![]() |
The Complete Log4j Manual by Ceki Gulcu Edition: Paperback |
Introduction
Log4j is an open source tool (OSS) developed for inserting logs statements into your application and was developed by people at Apache fundation. It's speed and flexibility allows log statements to remain in shipped code while giving the user the ability to enable logging at runtime without modifying any of the application binary. All of this while not incurring a high performance cost/loss.
Requirements
Why inserting log statement or rely on this (old) technology?
| Advantages | Drawbacks |
| It offers several advantages. It provides precise context about a run of the application. Once inserted into the code:
|
But
|
Why choosing Log4J? (From apache.org)
Log4j concepts
| Logger | Logger are responsible for handling the majority of log operations. The logger is the core component of the logging process. |
| Levels | Log4j by default can log messages with five priority levels (not including custom Levels). More can be defined by subclassing, but it is not recommended. debug to write debugging messages which should not be printed when the application is in production. fatal for critical messages, after logging of which the application quits abnormally A logger will only output messages that are of a level greater than or equal to it. If the level of a logger is not set it will inherit the level of the closest ancestor. So if a logger is created in the package com.waltercedric.account and no level is set for it, it will inherit the level of the logger created in com.waltercedric. If no logger was created in com.waltercedric., the logger created in com.waltercedric.balance will inherit the level of the root logger, the root logger is always instantiated and available. |
| Appender | Appender
The Appenders available are ( from the log4j API)
One may also implement the Appender interface to create ones own ways of outputting log statements. |
| Layout | Layout:
There are three types of Layout available:
|
Using Log4j in your code
It is not recommended to use log4j api directly, since who knows if a better logging framework won't do better in the future or if log4j won't modify its api's. The main idea is that when you aquire a 3rd party component, is to build a wrapper around it. It is even better if the wrapper contains an abstract factory: maybe in some case you wil have to use different class of logging (because of performance, licence...)
| A simple log4j wrapper |
| Import com.waltercedric.LogWrapper; public LogWrapper { ... |
| Using your newly created wrapper |
| Import com.waltercedric.LogWrapper; public void init() throws com.waltercedric.applicationException { LogWrapper logger = new LogWrapper(Account.class); |
Log4j Guidelines
The FAQ of log4J is a must to read, here are the most important points:
| public class Mamals { protected static LoggerWrapper logger = LogFactory.getLog(Mamals.class); ... } |
| and use it in all children |
| public class Human extends Mamals {
public Human() { } |
| l.debug("Cash balance is " + cashvalue); |
| use instead |
| if(myLogger.isDebugEnabled()) { myLogger.debug("Cash balance is " + cashBalance.toXML()); } |
- It is very simple to implement.
- It is very simple to explain to new developers.
- It automatically mirrors your application's own modular design.
- It can be further refined at will.
- Printing the logger automatically gives information on the locality of the log statement.
However, this is not the only way for naming loggers. A common alternative is to name loggers by functional areas. For example, the "database" logger, "RMI" logger, "security" logger, or the "XML" logger. You are totally free in choosing the names of your loggers. The log4j package merely allows you to manage your names in a hierarchy. However, it is your responsibility to define this hierarchy. Note by naming loggers by locality one tends to name things by functionality, since in most cases the locality relates closely to functionality.
Remote logging over TCP
Read carefully: http://jakarta.apache.org/log4j/docs/api/org/apache/log4j/net/SocketAppender.html and
http://jakarta.apache.org/log4j/docs/api/org/apache/log4j/net/SocketHubAppender.html
Starting the server .Chainsaw
Chainsaw is a graphical logging client, where you can see, sort and filter logs data.
Documentation can be read here: http://jakarta.apache.org/log4j/docs/api/org/apache/log4j/chainsaw/package-summary.html and it is a part of log4j.jar
| Starting chainsaw |
| c:jdk1.4.2binjava org.apache.log4j.chainsaw.Main "chainsaw.port", "5000" |
| Example of TCP appender in log4j.xml |
| log4j.appender.remote =org.apache.log4j.net.SocketAppender log4j.appender. remote.RemoteHost=localhost log4j.appender. remote.Port=5000 log4j.appender. remote.LocationInfo=true |
On the server side (where your application create logs), you will need to run log4j's SocketServer class. You can create a configuration file with configuration information similar to the following: The whole applcation is in DEBUG mode
| Example of socketserver.properties |
| log4j.rootCategory=DEBUG,log1 ############################ # log1 is set to be a file log4j.appender.log1=org.apache.log4j.RollingFileAppender log4j.appender.log1.MaxFileSize=100KB log4j.appender.log1.MaxBackupIndex=1 log4j.appender.log1.File=c://logs.log log4j.appender.log1.append = true log4j.appender.log1.layout=org.apache.log4j.PatternLayout log4j.appender.log1.layout.ConversionPattern=%p %t %c - %m%n |
| Start the server |
| java org.apache.log4j.net.SocketServer 5000 C:socketserver.properties C:temp org.apache.log4j.net.SocketServer "5000", "C:socketserver.properties", "C:temp" |
Start your application, without doing any change in your code or recompiling it, you can now log data remotely!
Configuring log4j
Location of configuration file
The configuration files of log4j must be in classpath, if more than one are in classpath, the first found will be used. Log4j require to have a compatible parser in classpath in order to read the configuration file. As default, Logj use Crimson.jar
Location of DTD
The DTD is needed in order to initialize log4j, 2 solutions are available:
| Public DTD, the file must be on internet or on network | System path, but with a fix path (URI) |
"http://www.waltercedric.com/log4j.dtd"> |
Extending log4j
Defining your application specific loggers, appenders and layouts
You can look at the Log4j API to see how to implement a logger, appender and layout.
Conclusions
One of the strength of log4j is that is do not require to recompile the java code to binary classes to change considerably the ouput amount in logs. You can add logging statements in your code, and without changing the code shipped, change at runtime the amount of log output. Thus the major behaviour logging strategies are done in this file (it can be a properties file or a XML file). You should store this file in the classpath of your application.
Annexes
Example of configuration files:
| Example of log4j.xml |
| Example of log4j.properties |
| ########################################################################### # # log4Java properties # # Documentation can be found at http://jakarta.apache.org/log4j/docs/api/index.html # There is no other documentation except forum, a commercial book is due (oreilly) # # To permit reloading during runtime, the LogDecorator will test each 60s if the file has changed # and update configuration of log4j if needed # # Ascending prioriy INFO < WARNING < DEBUG < ERROR < FATAL # log visible only if current log level >= defined level # # current layout can be: DateLayout, HTMLLayout, PatternLayout, SimpleLayout, XMLLayout # ########################################################################### # Set root logger level to [FATAL|ERROR|WARN|INFO|DEBUG], and provide default appender log4j.rootLogger=DEBUG, stdout ############################ # define category (and their level [INHERITED|FATAL|ERROR|WARN|INFO|DEBUG] and appender) # category should be fully qualified class name or incomplete package name # Note that you inherit from the root logger otherwise specified (set addtivity flag) # # additivity= true (default) all request will also be forwarded to the hierarchy # -> log twice if the same appender is already in the hierarchy # additivity= false do not forward to ancestor appenders # # INHERITED can be optionally specified which means that named category should inherit # its priority from the category hierarchy. If you add the flag additivity to false, # you do not inherit of appender ## log4j.category.com.waltercedric.account=INHERIT, log1 log4j.additivity.com.waltercedric.account=false log4j.category.com.waltercedric=DEBUG, log1 ######################################################## # You Can defined as many appender as you want ######################################################## ############################ # stdout is set to be a ConsoleAppender. ## log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout #see http://jakarta.apache.org/log4j/docs/api/org/apache/log4j/PatternLayout.html log4j.appender.stdout.layout.ConversionPattern=%d %r [%t] %-5p %c - %m%n ################################## # log1 is set to be a file by date log4j.appender.log1=org.apache.log4j.DailyRollingFileAppender #rollover each day at midnight, see DailyRollingFileAppender object log4j.appender.log1.DatePattern='.'yyyy-MM- dd #by size ##log4j.appender.log1=org.apache.log4j.RollingFileAppender ##log4j.appender.log1.MaxFileSize=100KB ##log4j.appender.log1.MaxBackupIndex=1 #/WEB-INF/conf/Log4j.properties log4j.appender.log1.File=c://VirtualTransport.log log4j.appender.log1.append = true log4j.appender.log1.layout=org.apache.log4j.PatternLayout #see http://jakarta.apache.org/log4j/docs/api/org/apache/log4j/PatternLayout.html #-4r [%t] %-5p %c %x - %m%n lead to 331 [main] ERROR com.waltercedric.account - classCastexception--> log4j.appender.log1.layout.ConversionPattern=%p %t %c - %m%n ############################ # eMail logging # # SMTPAppender will store all the logging events on an # internal cache and it will send all the messages when # the TriggeringEventEvaluator you set with the # setEvaluatorMethod or the constructor parameter return true. # By default the evaluator is set with an instance of # DefaultEvaluator wich is a package-private class # defined in the same compilation unit of SMTPAppender. # This evaluator will return true only when the logging # event has a priority greater or equal than ERROR. ## log4j.appender.email=org.apache.log4j.net.SMTPAppender log4j.appender.email.Threshold=FATAL log4j.appender.email.SMTPHost=XXX.XXX.XXX.XXX log4j.appender.email.To=name@company.com log4j.appender.email.From=name@company.com log4j.appender.email.Subject=A Fatal error has occured in your application log4j.appender.email.BufferSize=1 log4j.appender.email.layout=org.apache.log4j.PatternLayout #see http://jakarta.apache.org/log4j/docs/api/org/apache/log4j/PatternLayout.html log4j.appender.email.ConversionPattern=%d{ABSOLUTE} (%F:%L) - %m%n ############################ # remote socket server logging # # The SocketAppender has the following properties: # please read: http://jakarta.apache.org/log4j/docs/api/org/apache/log4j/net/SocketAppender.html # # If you want to have a server that listen, you can start the following utilities Chainsaw # (swing gui) read how at http://jakarta.apache.org/log4j/docs/api/org/apache/log4j/chainsaw/package-summary.html # Chainsaw is a particular server! ## log4j.appender.CHAINSAW_CLIENT=org.apache.log4j.net.SocketAppender log4j.appender.CHAINSAW_CLIENT.RemoteHost=localhost log4j.appender.CHAINSAW_CLIENT.Port=5000 log4j.appender.CHAINSAW_CLIENT.LocationInfo=true |
Resources
Privacy Statement | Copyright Notice | Licenses
© 1999-2012 Waltercedric.com. Designed by Cédric Walter. Sitemap
Reproduction without explicit permission is prohibited. All Rights Reserved. All photos remain copyright © their rightful owners. No copyright infringement is intended.
Disclaimer: The editor(s) reserve the right to edit any comments that are found to be abusive, offensive, contain profanity, serves as spam, is largely self-promotional, or displaying attempts to harbour irrelevant text links for any purpose.