Example usage for java.util.logging Logger getLogger

List of usage examples for java.util.logging Logger getLogger

Introduction

In this page you can find the example usage for java.util.logging Logger getLogger.

Prototype




@CallerSensitive
public static Logger getLogger(String name) 

Source Link

Document

Find or create a logger for a named subsystem.

Usage

From source file:gentracklets.Propagate.java

public static void main(String[] args) throws OrekitException {

    // load the data files
    File data = new File("/home/zittersteijn/Documents/java/libraries/orekit-data.zip");
    DataProvidersManager DM = DataProvidersManager.getInstance();
    ZipJarCrawler crawler = new ZipJarCrawler(data);
    DM.clearProviders();//from ww  w .  j a  va 2 s  .co m
    DM.addProvider(crawler);

    // Read in TLE elements
    File tleFile = new File("/home/zittersteijn/Documents/TLEs/ASTRA20151207.tle");
    FileReader TLEfr;
    Vector<TLE> tles = new Vector<>();
    tles.setSize(30);

    try {
        // read and save TLEs to a vector
        TLEfr = new FileReader("/home/zittersteijn/Documents/TLEs/ASTRA20151207.tle");
        BufferedReader readTLE = new BufferedReader(TLEfr);

        Scanner s = new Scanner(tleFile);

        String line1, line2;
        TLE2 tle = new TLE2();

        int nrOfObj = 4;
        for (int ii = 1; ii < nrOfObj + 1; ii++) {
            System.out.println(ii);
            line1 = s.nextLine();
            line2 = s.nextLine();
            if (TLE.isFormatOK(line1, line2)) {
                tles.setElementAt(new TLE(line1, line2), ii);
                System.out.println(tles.get(ii).toString());
            } else {
                System.out.println("format problem");
            }

        }
        readTLE.close();

        // define a groundstation
        Frame inertialFrame = FramesFactory.getEME2000();
        TimeScale utc = TimeScalesFactory.getUTC();
        double longitude = FastMath.toRadians(7.465);
        double latitude = FastMath.toRadians(46.87);
        double altitude = 950.;
        GeodeticPoint station = new GeodeticPoint(latitude, longitude, altitude);
        Frame earthFrame = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
        BodyShape earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS,
                Constants.WGS84_EARTH_FLATTENING, earthFrame);
        TopocentricFrame staF = new TopocentricFrame(earth, station, "station");

        Vector<Orbit> eles = new Vector<>();
        eles.setSize(tles.size());
        for (int ii = 1; ii < nrOfObj + 1; ii++) {
            double a = FastMath.pow(Constants.WGS84_EARTH_MU / FastMath.pow(tles.get(ii).getMeanMotion(), 2),
                    (1.0 / 3));
            // convert them to orbits
            Orbit kep = new KeplerianOrbit(a, tles.get(ii).getE(), tles.get(ii).getI(),
                    tles.get(ii).getPerigeeArgument(), tles.get(ii).getRaan(), tles.get(ii).getMeanAnomaly(),
                    PositionAngle.MEAN, inertialFrame, tles.get(ii).getDate(), Constants.WGS84_EARTH_MU);

            eles.setElementAt(kep, ii);

            // set up propagators
            KeplerianPropagator kepler = new KeplerianPropagator(eles.get(ii));

            System.out.println("a: " + a);

            // Initial state definition
            double mass = 1000.0;
            SpacecraftState initialState = new SpacecraftState(kep, mass);

            // Adaptive step integrator
            // with a minimum step of 0.001 and a maximum step of 1000
            double minStep = 0.001;
            double maxstep = 1000.0;
            double positionTolerance = 10.0;
            OrbitType propagationType = OrbitType.KEPLERIAN;
            double[][] tolerances = NumericalPropagator.tolerances(positionTolerance, kep, propagationType);
            AdaptiveStepsizeIntegrator integrator = new DormandPrince853Integrator(minStep, maxstep,
                    tolerances[0], tolerances[1]);

            NumericalPropagator propagator = new NumericalPropagator(integrator);
            propagator.setOrbitType(propagationType);

            // set up and add force models
            double AMR = 4.0;
            double crossSection = mass * AMR;
            double Cd = 0.01;
            double Cr = 0.5;
            double Co = 0.8;
            NormalizedSphericalHarmonicsProvider provider = GravityFieldFactory.getNormalizedProvider(4, 4);
            ForceModel holmesFeatherstone = new HolmesFeatherstoneAttractionModel(
                    FramesFactory.getITRF(IERSConventions.IERS_2010, true), provider);
            SphericalSpacecraft ssc = new SphericalSpacecraft(crossSection, Cd, Cr, Co);
            PVCoordinatesProvider sun = CelestialBodyFactory.getSun();
            SolarRadiationPressure srp = new SolarRadiationPressure(sun,
                    Constants.WGS84_EARTH_EQUATORIAL_RADIUS, ssc);

            //                propagator.addForceModel(srp);
            //                propagator.addForceModel(holmesFeatherstone);
            propagator.setInitialState(initialState);

            // propagate the orbits with steps size and tracklet lenght at several epochs (tracklets)
            Vector<AbsoluteDate> startDates = new Vector<>();
            startDates.setSize(1);
            startDates.setElementAt(new AbsoluteDate(2016, 1, 26, 20, 00, 00, utc), 0);

            // set the step size [s] and total length
            double tstep = 100;
            double ld = 3;
            double ls = FastMath.floor(ld * (24 * 60 * 60) / tstep);
            System.out.println(ls);

            SpacecraftState currentStateKep = kepler.propagate(startDates.get(0));
            SpacecraftState currentStatePer = propagator.propagate(startDates.get(0));

            for (int tt = 0; tt < startDates.size(); tt++) {

                // set up output file
                String app = tles.get(ii).getSatelliteNumber() + "_" + startDates.get(tt) + ".txt";

                // with formatted output
                File file1 = new File("/home/zittersteijn/Documents/propagate/keplerian/MEO/" + app);
                File file2 = new File("/home/zittersteijn/Documents/propagate/perturbed/MEO/" + app);
                file1.createNewFile();
                file2.createNewFile();
                Formatter fmt1 = new Formatter(file1);
                Formatter fmt2 = new Formatter(file2);

                for (int kk = 0; kk < (int) ls; kk++) {
                    AbsoluteDate propDate = startDates.get(tt).shiftedBy(tstep * kk);
                    currentStateKep = kepler.propagate(propDate);
                    currentStatePer = propagator.propagate(propDate);

                    System.out.println(currentStateKep.getPVCoordinates().getPosition() + "\t"
                            + currentStateKep.getDate());

                    // convert to RADEC coordinates
                    double[] radecKep = conversions.geo2radec(currentStateKep.getPVCoordinates(), staF,
                            inertialFrame, propDate);
                    double[] radecPer = conversions.geo2radec(currentStatePer.getPVCoordinates(), staF,
                            inertialFrame, propDate);

                    // write the orbit to seperate files with the RA, DEC, epoch and fence given
                    AbsoluteDate year = new AbsoluteDate(YEAR, utc);
                    fmt1.format("%.12f %.12f %.12f %d%n", radecKep[0], radecKep[2],
                            (currentStateKep.getDate().durationFrom(year) / (24 * 3600)), (tt + 1));
                    fmt2.format("%.12f %.12f %.12f %d%n", radecPer[0], radecPer[2],
                            (currentStateKep.getDate().durationFrom(year) / (24 * 3600)), (tt + 1));

                }
                fmt1.flush();
                fmt1.close();
                fmt2.flush();
                fmt2.close();

            }
            double[] radecKep = conversions.geo2radec(currentStateKep.getPVCoordinates(), staF, inertialFrame,
                    new AbsoluteDate(startDates.get(0), ls * tstep));
            double[] radecPer = conversions.geo2radec(currentStatePer.getPVCoordinates(), staF, inertialFrame,
                    new AbsoluteDate(startDates.get(0), ls * tstep));
            double sig0 = 1.0 / 3600.0 / 180.0 * FastMath.PI;
            double dRA = radecKep[0] - radecPer[0] / (sig0 * sig0);
            double dDEC = radecKep[2] - radecPer[2] / (sig0 * sig0);

            System.out.println(dRA + "\t" + dDEC);

        }

    } catch (FileNotFoundException ex) {
        Logger.getLogger(GenTracklets.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException iox) {
        Logger.getLogger(GenTracklets.class.getName()).log(Level.SEVERE, null, iox);
    }

}

From source file:PieChartCreate.PieChart_AWT.java

private static PieDataset createDataset(ResultSet resultSet) {
    try {//  ww  w .j a  v  a  2  s.  co m
        DefaultPieDataset dataset = new DefaultPieDataset();

        while (resultSet.next()) {
            dataset.setValue(resultSet.getString(1), new Double(resultSet.getString(2)));
        }
        return dataset;
    } catch (SQLException ex) {
        Logger.getLogger(PieChart_AWT.class.getName()).log(Level.SEVERE, null, ex);
    }
    return null;
}

From source file:com.searchbox.utils.DecryptLicense.java

private static boolean checkDate(String dateString) {
    try {/* ww w.  java2 s .  co  m*/
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        return format.parse(dateString).after(new Date());
    } catch (ParseException ex) {
        Logger.getLogger(DecryptLicense.class.getName()).log(Level.SEVERE, null, ex);
    }
    return false;
}

From source file:model.EmailJava.java

public static void enviarEmail(String userEmail) {
    try {//from   w ww.  java  2  s  . c  o m
        Email email = new SimpleEmail();
        email.setHostName("smtp.googlemail.com");
        email.setSmtpPort(465);
        //email.setAuthenticator(new DefaultAuthenticator("username", "password"));
        email.setAuthentication("codbarzmgbr@gmail.com ", "streetworkout2014");
        email.setSSLOnConnect(true);

        email.setFrom("jpmuniz88@gmail.com");

        email.setSubject("CodbarZ");
        email.setMsg("Junte-se ao CodbarZ. \n" + "Atleta junte-se ao nosso time, \n"
                + "empreendedores junte-se para nos apoiar, \n"
                + "Associe essa ideia, um projeto de inovado e aberto a todos que desejar evoluir com CodbarZ");
        email.addTo(userEmail);
        email.send();

    } catch (EmailException ex) {
        Logger.getLogger(EmailJava.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.incosyz.sms.other.UploadBackup.java

public static void uploadBackup(String filePath, String fileName) {
    String server = "ftp.bambooblindslanka.com";
    int port = 21;
    String user = "samagi@bambooblindslanka.com";
    String pass = "fs82xKzHZvtU";

    FTPClient client = new FTPClient();
    try {//from   w w  w. j  a  v a2  s  . co m
        client.connect(server, port);
        client.login(user, pass);
        client.enterLocalPassiveMode();
        client.setFileType(FTP.BINARY_FILE_TYPE);
        File firstLocalFile = new File(filePath);

        String firstRemoteFile = fileName;
        InputStream inputStream = new FileInputStream(firstLocalFile);

        boolean done = client.storeFile(firstRemoteFile, inputStream);
        inputStream.close();
    } catch (IOException ex) {
        Logger.getLogger(UploadBackup.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:controllers.FormsController.java

private static Properties getPropertyFile() {
    Properties properties = new Properties();
    InputStream stream = Play.application().classloader().getResourceAsStream("forms_en.properties");
    try {/*ww  w .  j  a v a2s  . c om*/
        properties.load(stream);
        stream.close();
        return properties;
    } catch (FileNotFoundException ex) {
        Logger.getLogger(FormsController.class.getName()).log(Level.SEVERE, null, ex);
        return null;
    } catch (IOException ex) {
        Logger.getLogger(FormsController.class.getName()).log(Level.SEVERE, null, ex);
        return null;
    } finally {
        try {
            stream.close();
        } catch (IOException ex) {
            Logger.getLogger(FormsController.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

From source file:jshm.logging.Log.java

public static void configTestLogging() {
    Handler consoleHandler = new ConsoleHandler();
    consoleHandler.setLevel(Level.ALL);
    consoleHandler.setFormatter(new OneLineFormatter());

    Logger cur = Logger.getLogger("");
    removeHandlers(cur);/*from   w  w  w  . j  av a 2  s . c o  m*/
    //      cur.setLevel(Level.ALL);

    cur.addHandler(consoleHandler);

    cur = Logger.getLogger("jshm");
    cur.setLevel(Level.ALL);

    cur = Logger.getLogger("httpclient.wire.header");
    cur.setLevel(Level.ALL);

    //      cur = Logger.getLogger("org.hibernate");
    //      removeHandlers(cur);
    //      
    //      cur.setLevel(Level.INFO);
}

From source file:com.credomatic.gprod.db2query2csv.Security.java

/**
 * Codifica a base 64 una cadena de caracteres.
 * @param value Cadena de caracteres que debe ser codificada en base 64
 * @return la cadena codificada como un areglo de bytes.
 *//*from   w w  w.j  a va2  s  .c om*/
public static byte[] encodeToBase64(final String value) {
    try {
        return Base64.encodeBase64(value.getBytes("ISO-8859-1"));
    } catch (UnsupportedEncodingException ex) {
        Logger.getLogger(Security.class.getName()).log(Level.SEVERE, null, ex);
    }
    return null;
}

From source file:iracing.webapi.LicenseGroupParser.java

public static List<LicenseGroup> parse(String json) {
    JSONParser parser = new JSONParser();
    List<LicenseGroup> output = null;
    try {/*from   www  .jav a 2  s.  c om*/
        JSONArray rootArray = (JSONArray) parser.parse(json);
        output = new ArrayList<LicenseGroup>();
        for (int i = 0; i < rootArray.size(); i++) {
            JSONObject r = (JSONObject) rootArray.get(i);
            LicenseGroup lg = new LicenseGroup();
            lg.setId(getInt(r, "group"));
            lg.setName(getString(r, "name", true));
            // NOTE: the following aren't specified if not applicable
            Object o = r.get("minNumTT");
            if (o != null)
                lg.setMinimumNumberOfTimeTrials(((Long) o).intValue());
            o = r.get("minNumRaces");
            if (o != null)
                lg.setMinimumNumberOfRaces(((Long) o).intValue());
            output.add(lg);
        }
    } catch (ParseException ex) {
        Logger.getLogger(LicenseGroupParser.class.getName()).log(Level.SEVERE, null, ex);
    }
    return output;
}

From source file:it.cnr.ilc.ilcioutils.IlcInputToFile.java

/**
 * Creates a file with the content read from the URL
 * @param theUrl the URL where the content is
 * @return a File with the content from the URL
 */// w  w w. j a v  a 2s  . c o m
public static File createAndWriteTempFileFromUrl(String theUrl) {
    File tempOutputFile = null;
    String message;
    try {
        tempOutputFile = File.createTempFile(TEMP_FILE_PREFIX, TEMP_FILE_SUFFIX);

        FileUtils.copyURLToFile(new URL(theUrl), tempOutputFile);
    } catch (IOException e) {
        message = String.format("Error in accessing URL %s %s", theUrl, e.getMessage());
        Logger.getLogger(CLASS_NAME).log(Level.SEVERE, message);
    }
    return tempOutputFile;

}