Skip to content

Quick Start ​

Get up and running with Logstyx in under 5 minutes. This guide covers the basic setup for the most common use cases.

Prerequisites ​

Before you start, make sure you have:

  • A running Logstyx instance (see Getting Started)
  • Your Project ID from the Logstyx dashboard
  • For server-side: Your API Key
  • For React Native: Your App bundle identifier
  • For browser/React: Your allowed origin configured in the dashboard

Choose Your SDK ​

Pick the SDK that matches your environment:

bash
npm install github:devatlogstyx/logstyx-js-node#release
bash
npm install github:devatlogstyx/logstyx-js-express#release
bash
npm install github:devatlogstyx/logstyx-js-browser#release
bash
npm install github:devatlogstyx/logstyx-js-react#release
bash
npm install github:devatlogstyx/logstyx-js-react-native#release

Basic Setup ​

Server-Side (Node.js) ​

javascript
const useLogstyx = require('logstyx-js-node');

const logger = useLogstyx({
  projectId: 'your_project_id',
  apiKey: 'your_api_key',
  endpoint: 'https://your-domain.com/api/v1/logs', // Your Logstyx instance
  captureUncaught: true, // Optional: auto-capture uncaught errors
  captureUnhandledRejections: true, // Optional: auto-capture unhandled rejection
});

// Start logging
logger.info({ message: 'Application started' });
logger.error({ message: 'Something went wrong', error: err.message });

Client-Side (Browser/React) ​

javascript
import { useLogstyx } from 'logstyx-js-browser';

const logger = useLogstyx({
  projectId: 'your_project_id',
  endpoint: 'https://your-domain.com/api/v1/logs',
  captureUncaught: true, // Optional: auto-capture uncaught errors
  captureUnhandledRejections: true, // Optional: auto-capture unhandled rejection
});

logger.info({ message: 'Page loaded', page: window.location.pathname });

Origin Setup Required

Make sure to add your domain to the allowed origins in your Logstyx dashboard under Project Settings.

Mobile (React Native) ​

javascript
import { useLogstyx } from 'logstyx-js-react-native';

const logger = useLogstyx({
  projectId: 'your_project_id',
  appid: 'your_app_id',
  endpoint: 'https://your-domain.com/api/v1/logs',
});

logger.info({ message: 'App launched', platform: Platform.OS });

Log Levels ​

Logstyx supports four log levels:

javascript
logger.info({ message: 'Informational message' });
logger.warning({ message: 'Warning message' });
logger.error({ message: 'Error occurred' });
logger.critical({ message: 'Critical system failure' });

Adding Context ​

Add persistent context to all subsequent logs:

javascript
// Set context
logger.setContext({
  userId: '12345',
  environment: 'production',
});

// This log will include the context
logger.info({ message: 'User action' });
// Logs: { message: 'User action', userId: '12345', environment: 'production' }

// Clear specific keys
logger.clearContext(['userId']);

// Clear all context
logger.clearContext();

Self-Hosted Setup ​

If you're running Logstyx on your own infrastructure, just point the endpoint to your instance:

javascript
const logger = useLogstyx({
  projectId: 'your_project_id',
  apiKey: 'your_api_key',
  endpoint: 'https://logs.your-company.com/api/v1/logs', // Your domain
});

Error Capture ​

Enable automatic error capture to catch uncaught exceptions:

javascript
const logger = useLogstyx({
  projectId: 'your_project_id',
  apiKey: 'your_api_key',
  captureUncaught: true, // auto-capture uncaught errors
  captureUnhandledRejections: true, // auto-capture unhandled rejection
});

Verify It Works ​

  1. Send a test log:
javascript
logger.info({ message: 'Test log from quick start guide' });
  1. Open your Logstyx dashboard
  2. Navigate to your project
  3. You should see your log appear within 1-2 seconds

Common Issues ​

Logs not appearing?

  • Check your projectId is correct
  • Verify your endpoint URL is accessible
  • For browser/React: Ensure your origin is whitelisted in the dashboard
  • Check browser console or server logs for error messages

Authentication errors?

  • Server-side: Verify your apiKey is correct
  • React Native: Check your appid is valid
  • Browser/React: Confirm allowed origins are configured

Released under the MIT License.