Skip to main content

How to Create Our Custom Logs for Tomcat Server On EC2 Instance.

If you want to create our own custom logs then you have to create a property file under your java web project

1) In Property, the file will look like this one.

#Direct log message to stdout

log4j.rootLogger=INFO, ROOT
# at aws create a directory under /usr/ like "sudo mkdir othogologs" then create a file inside it like dump.log and assign access to this file chmod 777 dump.log



log4j.appender.ROOT.layout.ConversionPattern=[%d] %t %c %-5p - %m%n

First you have to create our own directory inside the home director  (Means under directly under / ) so here is usr directory you can create your directory inside the usr directory.

After creating directory inside the create your onemore direcotry so that you can keep your website logs their so i am using you directory name like "domainlogs" under this directory you have create a file like dump.log file and the you have to change premssion for this file 

chomd 777 dump.log

How to delete content from a file 

1) First, we have to check file size by the following command. 
I am here the location of a file and i have a file called dump.log

[root@ip-172-31-31-136 othogologs]# du -sh dump.log

it will show the output like 

[root@ip-172-31-31-136 othogologs]# du -sh dump.log
3.9M    dump.log

2) Now empty a file by the following command. 
[root@ip-172-31-31-136 othogologs]# 

# : > access.log
# true > access.log

Source :


Popular posts from this blog

How do I change the time zone of my Amazon RDS database instance?

As we know bydefault time in the format of UTC in mysql.We can set local time zone to our AWS RDS Instance for our application. or any other time zone prefared Cloud Based Website Hosting Service Provider Steps 1: Go to Services and Select RDS Now to change time zone we have to change "Parameter Group" in left side that is associated with DB instance first we can check default Parameter Group for our instance is Parameter group default.mysql5.7  ( in-sync ) like this. So we have to change the time zone in this Parameter Group.  now open that parameter group (default.mysql5.7)  and click on edit parameter. then search for time_zone (because we want to change it.) then we have to change time_zone only by default it is engine-default (that is utc)  we have to select Asia/Calcutta.  More information we can ref.

Changing the Time Zone on Amazon Linux Ec2 Instance

Amazon Linux instances are set to the UTC (Coordinated Universal Time) time zone by default, but you may wish to change the time on an instance to the local time or to another time zone in your network. Important These procedures are intended for use with Amazon Linux. For more information about other distributions, see their specific documentation. To change the time zone on an instance Identify the time zone to use on the instance. The  /usr/share/zoneinfo  directory contains a hierarchy of time zone data files. Browse the directory structure at that location to find a file for your time zone. [ec2-user ~]$ ls /usr/share/zoneinfo Africa Chile GB Indian Mideast posixrules US America CST6CDT GB-Eire Iran MST PRC UTC Antarctica Cuba GMT MST7MDT PST8PDT WET Arctic EET GMT0 Israel Navajo right W-SU ... Some of the entries at this location are directo

Amazon EC2 Server Setup & Installing JDK 8 and Tomcat 8, Running on Port 80 & 443 and Redirect Request from port 80 to 8080 and 443 to 8443

Amazon EC2 Server Setup & Installing JDK 8 and Tomcat 8, Running on Port 80 & 443 and Redirect Request from port 80 to 8080 and 443 to 8443. Step 1 : Log in to your aws account by following this link then click on my account and choose option aws management console. Note: I am assuming you created your account with aws and you are ready with you account if you haven’t done then you can check out on google you will get many and it's a straight forward steps if you have still problem while creating an account you can comment in comment box i will also provide tutorial for that. Once you logged in aws management console you are able to see window like this one Note : Before we go ahead we have to select proper reason from right and side. I choose ohio region for this example. Step 2 : Now you have to choose EC2 Server from Services tab on left side top corner then choose EC2 Services from “Compute option ” You will get window like this one and r