This website uses cookies to ensure you get the best experience on our website.

Skip to content
LOGO
  • Company

    About IGNEK

    Learn about our story and our mission.

    Careers

    We're hiring!

    We always looking for talented peoples. Join our team!

    Blogs

    The latest industry news, updates and info.

    Case Studies

    Take a closer look at the projects we've delivered

    Webinar

    Watch our latest organized webinar

    Get in touch with our HR team

    • hr@ignek.com
    • +91 93284 95160
    • Ahmedabad, Gujarat, India – 382470
  • Services

    Enterprise Portal Development

    Custom Enterprise Portal Development for flawless Solutions

    Dedicated Development Team

    Expand Teams, Optimize Development with Our Expertise

    Back-end Development

    Empowering your digital presence with robust backend development expertise

    Front-end Development

    Crafting engaging user experiences through expert frontend development

    Digital Transformation

    Embrace digital transformation by modernizing process

    SaaS Development

    Transform your business with SaaS Innovative Solutions

    Technologies

    Liferay Services

    Development & Customization

    Theme

    Upgradation

    Migration

    Proof of Concept

    Performance Tunning

    Architecture

    Support & Maintenance

    E-commerce

    Expert Advice

    React Services

    Enterprise Development

    Custom Application

    Single Page Application

    Architecture

    API Integration

    Migration

    Consulting

    Maintenance & Support

    Spring Boot Services

    Web Service

    MVC Web Development

    API Integration

    Security

    Migration

    Microservices

    Support & Maintenance

    AEM Services

    Consulting Service

    Site Development

    Migration & Upgradation

    Integration

    Maintenance & Support

    Custom Solutions

    Content Management

    Team Augementation

  • Solution

    Ready for digital excellence

    In our rapidly evolving world, businesses are always on the lookout for fresh ways to improve their operations and connect with their audiences.

    Contact US

    Solutions

    SaaS : Software As A Service

    Transforming industries through cutting edge SaaS solutions.

    Customer Portal : Boost Business Productivity

    Streamline operations and enhance productivity with our Customer Portal solution.

    Liferay Based Intranet Portal

    Internal portal for company communication, collaboration and resources

    Integration

    Matomo Integration with Liferay

    Integrate Matomo to enable user interactions seamlessly.

    Microsoft Teams integration with Liferay

    Integrate to enable seamless collaboration, messaging within your portal.

    Jira Integration With Liferay

    Optimizes business operations by integrating with Jira.

  • Hire Us

    Liferay

    Get expert Liferay developers for seamless portal solutions.

    React JS

    Get expert ReactJS developers for dynamic web solutions.

    Web Developer

    Get custom web solutions from IGNEK's expert developers.

    Spring Boot

    Get top-notch Spring Boot developers for your project success!

    Healthcare

    Get top Healthcare Developers for cutting-edge medical software.

    MERN Stack

    Get expert MERN developers from IGNEK for custom, innovative project solutions.

    Why Hire Developers From IGNEK ?

    • Certified Developer
    • Transparent Communication
    • Flexible Hiring Modals
    • Fully Signed NDA
    • Cost Effective
    • Easy Exit Policy

    Get in touch with our Sales team

    • sales@ignek.com
    • +91 6351576580
    • info@ignek.com
    • Ahmedabad, Gujarat, India – 382470
SCHEDULE CALL
  • COMPANY
    • About
    • Case Studies
    • Blogs
    • Career
    • Webinar
  • SERVICES
    • Enterprise Portal Development
    • Dedicated Development Team
    • Back-end Development
    • Front-end Development
    • Digital Transformation
    • SaaS Development
  • SOLUTION
    • Customer Portal:  Boost Business Productivity
    • SaaS : Software as a Service
    • Liferay Based Employee Intranet Portal
  • TECHNOLOGY
    • Liferay Services
      • Liferay Development and Customization
      • Liferay Theme Development Service
      • Liferay DXP 7.4 Upgrade
      • Liferay Migration
      • Liferay Proof Of Concept
      • Liferay Performance Tuning
      • Liferay Architecture Design Service
      • Liferay Support And Maintenance Service
      • Liferay Ecommerce Development
      • Liferay Expert Advice
    • ReactJS Services
      • ReactJS Enterprise Application Development
      • ReactJS Custom Application Development
      • ReactJS Single Page Application Development (SPA)
      • ReactJS Applications Architecture
      • ReactJS API Integration
      • ReactJS Migration
      • ReactJS Consulting
      • ReactJS Maintenance and Support
    • Spring Boot Services
      • Spring Boot Web Development Service
      • Spring MVC Web Development
      • Spring Boot API Integration Service
      • Spring Boot Security
      • Spring Boot Migration Service
      • Spring Boot Microservices
      • Spring Boot Support & Maintenance Service
    • AEM Development Services
      • AEM Consulting Services
      • AEM Site Development
      • AEM Migration & Upgradation
      • AEM Integration Services
      • AEM Maintenance & Support
      • AEM Content Management
      • Custom AEM Solutions
      • AEM Team Augmentation
  • INTEGRATION
  • HIRE US
    • Hire Liferay Developer
    • Hire ReactJS Developer
    • Hire Spring Boot Developer
    • Hire Healthcare Developer
    • Hire Web Developer
    • Hire MERN Stack Developer
  • CONTACT US
  • Company

    About IGNEK

    Careers

    We're hiring!

    Blogs

    Case Studies

    Webinar

    Get in touch with our HR team

    • hr@ignek.com
    • +91 93284 95160
    • Ahmedabad, Gujarat, India – 382470
  • Services

    Enterprise Portal Development

    Dedicated Development Team

    Back-end Development

    Front-end Development

    Digital Transformation

    SaaS Development

    Technologies

    Liferay Liferay Services
    • Development & Customization
    • Theme
    • Upgradation
    • Migration
    • Proof of Concept
    • Performance Tuning
    • Architecture
    • Support & Maintenance
    • E-commerce
    • Expert Advice
    React React Services
    • Enterprise Development
    • Custom Application
    • Single Page Application
    • Architecture
    • API Integration
    • Migration
    • Consulting
    • Maintenance & Support
    Spring Boot Spring Boot Services
    • Web Service
    • MVC Web Development
    • API Integration
    • Security
    • Migration
    • Microservices
    • Support & Maintenance
    AEM AEM Services
    • Consulting Service
    • Site Development
    • Migration & Upgradation
    • Integration
    • Maintenance & Support
    • Custom Solutions
    • Content Management
    • Team Augmentation
  • Solution

    Ready for digital excellence

    In our rapidly evolving world, businesses are always on the lookout for fresh ways to improve their operations and connect with their audiences.

    Contact US

    Solutions

    SaaS : Software As A Service

    Customer Portal : Boost Business Productivity

    Liferay Based Intranet Portal

    Integration

    Matomo Integration with Liferay

    Microsoft Teams integration with Liferay

    Jira Integration With Liferay

  • Hire Us

    Liferay

    React JS

    Web Developer

    Spring Boot

    Healthcare

    MERN Stack

    Why Hire Developers From IGNEK ?

    • Certified Developer
    • Transparent Communication
    • Flexible Hiring Modals
    • Fully Signed NDA
    • Cost Effective
    • Easy Exit Policy

    Get in touch with our Sales team

    • sales@ignek.com
    • +91 6351576580
    • IGNEK
    • Ahmedabad, Gujarat, India – 382470
  • SCHEDULE CALL

Efficient Log Management in Liferay

  • Liferay
  • June 18, 2024

Share On :

Introduction:

Log management involves handling log files, which are files that record the events or activities of a system, program, or process. Log files are useful for debugging, monitoring, auditing, and analyzing the performance and behavior of the system, program, or process. Log files can also help to identify and resolve errors, problems, or security issues.

Liferay logs are critical for monitoring and debugging, but managing them efficiently is equally important. In this guide, we’ll explore how to copy log files from a Liferay server to a local folder without deleting them, using the log rotation tool, logrotate.

You can utilize the administrative privileges to navigate to the log directory, typically located in the system’s file structure. Once there, employ logrotator commands or configurations to copy and manage log files, granting access to historical data and insights without direct server access. This method allows administrators to maintain log integrity and efficiently manage system data without compromising security protocols.

Prerequisites:
      • Liferay 7.4
      • Logrotate

Step 1: Create a custom directory

    1. Ensure that you provide the required permissions while using the below command.
sudo nano /opt/liferay/logs

Step 2: Configure Logrotate

  1. Install logrotate
    • Install `logrotate` if it’s not already installed on your system. You can do this using the package manager for your Linux distribution.
sudo apt-get install logrotate
  1. Create a Configuration File
    • Create a custom configuration file for `logrotate` to manage the Liferay logs. For example, create a file named `liferay` in the `/etc/logrotate.d/` directory.
sudo nano /etc/logrotate.d/liferay
    • Add the following content in the file and save it .

/home/ignek/Work/Projects/Blog/Liferay-server/logs/liferay.*.log {

    copytruncate

    daily

    missingok

    rotate 1

    create 0666 root root

    prerotate

        scp /home/ignek/Work/Projects/Blog/Liferay-server/logs/liferay.*.log /opt/liferay/logs

        chmod 0664 /opt/liferay/logs/liferay.*.log

    endscript

    postrotate

       scp /opt/liferay/logs/liferay.*.log /home/ignek/Work/Projects/Blog/Liferay-server/logs

        rm /home/ignek/Work/Projects/Blog/Liferay-server/logs/liferay.*.log.1

    endscript

}

Script to copy log file

Step 3: Run Log Rotation Manually

logrotate -f /etc/logrotate.d/liferay

Now ensure that all the log files from Liferay logs are copied into opt/liferay/logs directory.

Step 4: Automation (Optional)

  • Schedule log rotation using a cron job to automate the process at regular intervals.
sudo crontab -e
  • Add below script in it.
0 2 * * * /usr/sbin/logrotate /etc/logrotate.conf
log management
  • This cron job entry specifies:
    •  ‘0’  as the minute,
    •  ‘2’  as the hour (2 AM),
    •  ‘*’  for every day of the month,
    •  ‘*’  for every month
    •  ‘*’  for every day of the week.

logrotate will be executed automatically at 2 AM daily to manage and rotate your Liferay logs. Adjust the cron job schedule based on your preferences.

Step 5: Write a Groovy script to view the log file in Liferay

  • First, navigate to Liferay’s control panel/server Administration/script.
Navigate to Script
  • Now add the below groovy script in the script box.
Groovy Script to view log file

def logFilePath = “/opt/liferay/logs/liferay.2024-02-14.log”

try {

    def logFile = new File(logFilePath)

    if (logFile.exists()) {

        def linesToRead = 2000

        def command = “tail -n $linesToRead $logFilePath”

        def process = command.execute()

        def reader = new BufferedReader(new InputStreamReader(process.inputStream))

        reader.eachLine { line ->

            println line

        }

        reader.close()

    } else {

        println “Log file does not exist: $logFilePath”

    }

} catch (Exception e) {

    println “Error reading log file: $e.message”

    e.printStackTrace()

}

Provided Groovy script reads the last 2000 lines of a log file (/opt/liferay/logs/liferay.2024-02-14.log) using the tail command. Let’s break down the script step by step,

  • def logFilePath = “/opt/liferay/logs/liferay.2024-02-14.log”
    • Defined the path of the log file.
    • If you want to get a log for a specific date then replace the date in the highlighted place below..
      • /opt/liferay/logs/liferay.YYYY-MM-DD.log

def logFile = new File(logFilePath)

It creates a File object (logFile) representing the log file.

  • if (logFile.exists())
    • It will check if the file exists or not.
  • def linesToRead = 2000
    • If the log file exists, it defines the number of lines to read (linesToRead).
  • def command = “tail -n $linesToRead $logFilePath”
    • It constructs the tail command to read the specified number of lines.
  • def process = command.execute()
    • It executes the tail command using execute() to get the process.
  • def reader = new BufferedReader(new InputStreamReader(process.inputStream))
    • It creates a reader to read the output of the tail command.
  • reader.eachLine { line -> println line }
    • It iterates over each line of the output and prints it.
  • else { println “Log file does not exist: $logFilePath” }
    • If the log file does not exist, it prints a message.
  • catch (Exception e) {

println “Error reading log file: $e.message”

e.printStackTrace()

}

    • It handles any exceptions that may occur during the process and prints an error message.
Output of log
Conclusion:

Managing log files effectively is essential for keeping any system, including Liferay, running smoothly and securely. With Logrotate, administrators can automate the copying and management of Liferay logs, making sure vital log data is preserved and readily available for debugging, monitoring, and analysis.

Explore Our Services

Discover how we can help your business thrive, whether you’re running a small startup, an SME, or a large enterprise. We’re here to understand your unique needs and goals, offering the expertise and resources to support your journey to success.

Stay informed about our Liferay services and updates by subscribing to our newsletter—just fill in the details below to subscribe.

Loading
Loading...

Related Blogs

July 1, 2020
Change-look-and-feel-of-control-panel-Cover Image
Change look and feel of control panel
August 5, 2022
Liferay server autostart script in ubuntu cover Image
Liferay server autostart script in ubuntu
March 28, 2024
Performance Tuning With Liferay
Loading...

Featured Projects Portfolios

October 4, 2023
Telemedicine Appointment & Health Record Portal
Telemedicine Appointment & Health Record Portal
October 3, 2023
Simplify Approvals and Goals With Agenda & Meeting SaaS Platform
Simplify Approvals and Goals With Agenda & Meeting SaaS Platform
October 3, 2023
Streamlining Global Communication with a Unified Digital Platform
Streamlining Global Communication with a Unified Digital Platform

Digital Solutions for Your Business with IGNEK

4.9

5.0

5.0

5.0

LOGO

Making the world a better place through constructing elegant hierarchies

COMPANY

  • About
  • Career
  • Case Study
  • Blogs

SERVICES

  • Enterprise Portal Development
  • Dedicated Development Team
  • Back-end Development
  • Front-end Development
  • Digital Transformation
  • SaaS Development

HIRE US

  • Liferay
  • Spring Boot
  • ReactJS
  • Healthcare
  • MERN Stack
  • AEM

CONTACT

  • info@ignek.com
  • info@ignek.com
SALES
  • sales@ignek.com
  • (+91) 635 157 6580
CAREER
  • hr@ignek.com
  • (+91) 932 849 5160
  • E 910-912, Ganesh Glory 11, Jagatpur Road, SG Highway, Ahmedabad, Gujarat - 382470

© 2018-2025 IGNEK, Inc. All rights reserved

Linkedin Facebook X-twitter Instagram