Audit Log
Tag: Log
Limited Time Offer!
For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!
Top 5 Log Monitoring Tools | List of Log Monitoring Tools | scmGalaxy
- Extended functionality via plugins.
- Free and open source.
- Filters are code.
- Great integration with other Elastic products.
2. Fluentd
- Handles up to 50,000 messages per second at peak time
- Data filtering and alerting
- Apache 2.0 License project
- Simplify and scale data pipeline management with tags
- More than 200 community-contributed plugins
- Real-time monitoring and alerts system
- Store data in multiple systems
- Collect and correlate web server access logs and application error logs
3. Loggly
- Text-based logs from any source
- Custom source groups
- Point-and-click trending graphs
- Automated filters and event parsing
- Full-system RESTful API to integrate with other applications
- Unlimited saved searches and users
- Adaptable interface with multiple views, pages and workspaces
- Unlimited custom dashboards based on any search
- Built-in customizable alerts with triggers
4. Graylog2
- Leverages Java, Scala and ElasticSearch technologies
- Central syslog monitoring
- Interactive API browser
- Application debugging
- Exception monitoring
- API analytics
- Intuitive search interface
- Comprehensive dashboard
5. Splunk
- Works with Hadoop & NoSQL
- Setup standard searches as real-time alerts
- Trigger automatic responses
- Scale from a single server to multiple data centers
- Deployable to on premise sites, hybrid-cloud, and/or private and public cloud based infrastructures
- Securely make data available
- Supports various use cases including log consolidation/retention, security, compliance reporting, and more
- Perform ad hoc queries
How to attach the jenkins build log as part of the email body?
How to attach the jenkins build log as part of the email body?
Way 1 –
Put following lines as part of Default Content text box
${BUILD_LOG, maxLines=9999, escapeHtml=false}
this works for free style projects
Way 2 – If you want send only specific line using regex
${BUILD_LOG_REGEX, regex=”\\b(Buildfile|BUILD)\\b”, linesAfter=1}
${BUILD_LOG_REGEX, regex=”^.*?BUILD FAILED.*?$”, linesBefore=0, linesAfter=10, maxMatches=5, showTruncatedLines=false, escapeHtml=true}
${BUILD_LOG_REGEX, regex=”\\b(FC0)\\b”, linesAfter=1}
${BUILD_LOG_REGEX, regex=”^.*?BUILD FAILED.*?$”, linesBefore=0, linesAfter=10, maxMatches=5, showTruncatedLines=false, escapeHtml=true}
${BUILD_LOG_REGEX, regex=”^.*?FC0.*?$”, maxMatches=95, showTruncatedLines=false, escapeHtml=false, matchedLineHtmlStyle=true}
This will show exactly which is expected lines as part of the regEx.
More Info
http://wiki.hudson-ci.org/display/HUDSON/Email-ext+plugin
http://champasoft.blogspot.nl/2012/11/jenkins-pattern-for-e-mailing-log.html
JUnit 4 Test Logging Tips using SLF4J
When writing JUnit tests developers often add log statements that can help provide information on test failures. During the initial attempt to find a failure a simple System.out.println() statement is usually the first resort of most developers.
Replacing these System.out.println() statements with log statements is the first improvement on this technique. Using SLF4J (Simple Logging Facade for Java) provides some neat improvements using parameterized messages. Combining SLF4J with JUnit 4 rule implementations can provide more efficient test class logging techniques.
Some examples will help to illustrate how SLF4J and JUnit 4 rule implementation offers improved test logging techniques. As mentioned the inital solution by developers is to use System.out.println() statements. The simple example code below shows this method.
01 import org.junit.Test;
02
03 public class LoggingTest {
04
05 @Test
06 public void testA() {
07 System.out.println(“testA being run…”);
08 }
09
10 @Test
11 public void testB() {
12 System.out.println(“testB being run…”);
13 }
14 }
The obvious improvement here is to use logging statements rather than the System.out.println() statements. Using SLF4J enables us to do this simply whilst allowing the end user to plug in their desired logging framework at deployment time. Replacing the System.out.println() statements with SLF4J log statements directly results in the following code.
view source
01 import org.junit.Test;
02 import org.slf4j.Logger;
03 import org.slf4j.LoggerFactory;
04
05 public class LoggingTest {
06
07 final Logger logger =
08 LoggerFactory.getLogger(LoggingTest.class);
09
10 @Test
11 public void testA() {
12 logger.info(“testA being run…”);
13 }
14
15 @Test
16 public void testB() {
17 logger.info(“testB being run…”);
18 }
19 }
Looking at the code it feels that the hard coded method name in the log statements would be better obtained using the @Rule TestName JUnit 4 class. This Rule makes the test name available inside method blocks. Replacing the hard coded string value with the TestName rule implementation results in the following updated code.
01 import org.junit.Rule;
02 import org.junit.Test;
03 import org.junit.rules.TestName;
04 import org.slf4j.Logger;
05 import org.slf4j.LoggerFactory;
06
07 public class LoggingTest {
08
09 @Rule public TestName name = new TestName();
10
11 final Logger logger =
12 LoggerFactory.getLogger(LoggingTest.class);
13
14 @Test
15 public void testA() {
16 logger.info(name.getMethodName() + ” being run…”);
17 }
18
19 @Test
20 public void testB() {
21 logger.info(name.getMethodName() + ” being run…”);
22 }
23 }
SLF4J offers an improved method to the log statement in the example above which provides faster logging. Use of parameterized messages enable SLF4J to evaluate whether or not to log the message at all. The message parameters will only be resolved if the message will be logged. According to the SLF4J manual this can provide an improvement of a factor of at least 30, in case of a disabled logging statement.
Updating the code to use SLF4J parameterized messages results in the following code.
01 import org.junit.Rule;
02 import org.junit.Test;
03 import org.junit.rules.TestName;
04 import org.slf4j.Logger;
05 import org.slf4j.LoggerFactory;
06
07 public class LoggingTest {
08
09 @Rule public TestName name = new TestName();
10
11 final Logger logger =
12 LoggerFactory.getLogger(LoggingTest.class);
13
14 @Test
15 public void testA() {
16 logger.info(“{} being run…”, name.getMethodName());
17 }
18
19 @Test
20 public void testB() {
21 logger.info(“{} being run…”, name.getMethodName()); }
22 }
23 }
Quite clearly the logging statements in this code don’t conform to the DRY principle.
Another JUnit 4 Rule implementation enables us to correct this issue. Using the TestWatchman we are able to create an implementation that overrides the starting(FrameworkMethod method) to provide the same functionality whilst maintaining the DRY principle. The TestWatchman Rule also enables developers to override methods invoked when the test finishes, fails or succeeds.
Using the TestWatchman Rule results in the following code.
01 import org.junit.Rule;
02 import org.junit.Test;
03 import org.junit.rules.MethodRule;
04 import org.junit.rules.TestWatchman;
05 import org.junit.runners.model.FrameworkMethod;
06 import org.slf4j.Logger;
07 import org.slf4j.LoggerFactory;
08
09 public class LoggingTest {
10
11 @Rule public MethodRule watchman = new TestWatchman() {
12 public void starting(FrameworkMethod method) {
13 logger.info(“{} being run…”, method.getName());
14 }
15 };
16
17 final Logger logger =
18 LoggerFactory.getLogger(LoggingTest.class);
19
20 @Test
21 public void testA() {
22
23 }
24
25 @Test
26 public void testB() {
27
28 }
29 }
And there you have it. A nice test code logging technique using JUnit 4 rules taking advantage of SLF4J parameterized messages.
I would be interested to hear from anyone using this or similar techniques based on JUnit 4 rules and SLF4J.
Reference: http://www.catosplace.net/