SoFunction
Updated on 2025-03-08

Share your own java log class and method code


import .*;
import ;
import .*;
import ;

public class AndyLogger
{
    //The defaulted root path of SSLVPN installation
    private static String rootPath = "C:\\temp2";

    //variable for creating new line
    private final static String enter = ("");

    private static SimpleDateFormat sdf =
        new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");

    public static synchronized void log(String fileName, String logMessage)
    {
        try
        {
            File folder = new File(rootPath);
            if(!())
            {
             ();
            }
            File file = new File(rootPath + "\\" + fileName + ".log");
            if(!())
            {
             ();
            }
            BufferedReader in = new BufferedReader(new FileReader(file));
            String str = "";
            String strToal = "";

            while ((str = ()) != null)
            {
                strToal += (str + enter);
            }    
            strToal = strToal + ((new Date()) + " " + logMessage + enter);
            ();
            BufferedWriter out = new BufferedWriter(new FileWriter(file));
            (strToal);
            ();

        }
        catch (Exception e)
        {
            ();
        }
    }

   
    public static synchronized void log(String fileName, String[] logMessages)
    {
        try
        {
            File folder = new File(rootPath);
            if(!())
            {
             ();
            }
            File file = new File(rootPath + "\\" + fileName + ".log");
            if(!())
            {
             ();
            }
            BufferedReader in = new BufferedReader(new FileReader(file));
            String str = "";
            String strToal = "";

            while ((str = ()) != null)
            {
                strToal += (str + enter);
            }
            for (int i=0; i < ; i++)
            {
               String logMessage = logMessages[i];
               strToal = strToal + ((new Date()) + " " + logMessage + enter);
            }
            ();
            BufferedWriter out = new BufferedWriter(new FileWriter(file));
            (strToal);
            ();

        }
        catch (Exception e)
        {
            ();
        }
    }
    public static void main(String args[])
    {
     ("bug223", "timeisjjja");
     String[] logMessages = {"111","222","333"};
     ("bug223", logMessages);
    }

}